File::x()

Gets the file extension.

Table of Contents
  1. Description
  2. Example

Description

File::x(): ?string;

This method returns the file extension if the file exists. It returns null if the file does not exist or if the file name does not contain a . character at all.

Example

$file = new File('.\path\to\file.txt');

$x = $file->x(); // Returns `'txt'`
$file = new File('.\path\to\FILE.TXT');

$x = $file->x(); // Returns `'txt'`
$file = new File('.\path\to\file');

$x = $file->x(); // Returns `null`
$file = new File('.\path\to\.file');

$x = $file->x(); // Returns `'file'`
$file = new File('.\path\to\file.');

$x = $file->x(); // Returns `""`

File::size()

Gets the file sizes in human readable string format.

File::x()

Gets the file extension.