File::__isset()

Checks if a method returns non-null value.

Table of Contents
  1. Description
  2. Example

Description

File::__isset(string $key): bool;

You won’t use this method directly, it will be executed automatically when you try to check the existence of a method or property using empty() or isset() language construct. In normal situations, this method doesn’t really need to exist because empty() and isset() can directly check the existence of a property in an object. But as this class also has a feature to invoke methods via property call syntax, then this method becomes useful when what is being checked is not a property value but is the return value of an invoked method.

Example

In the example below, isset() doesn’t check for the existence of name property because this property doesn’t exist in the File class instance. Instead, isset() checks if method File::name() returns a non-null value. That’s why this method returns true even though name property doesn’t actually exist.

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

test(isset($file->name)); // Returns `true`

File::__isset()

Checks if a method returns non-null value.

File::size()

Gets the file sizes in human readable string format.