File::from()

Object instantiator.

Table of Contents
  1. Description
  2. Example

Description

File::from(...$lot): self;

It is just a shortcut for the File::__construct() way.

Example

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

The example above is the same as the instantiation below:

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

Its purpose is to help you avoid using parentheses when you want to call a method directly from the class instance to minimize variable usage:

// Syntax error, unexpected token “->”, expecting “)”
$name = new File('.\path\to\file.txt')->name();

// :(
$file = new File('.\path\to\file.txt');
$name = $file->name();

$name = (new File('.\path\to\file.txt'))->name(); // :\
$name = File::from('.\path\to\file.txt')->name(); // :)

File::from()

Object instantiator.

File::size()

Gets the file sizes in human readable string format.