Skip to Content
Mastering PHP 7
book

Mastering PHP 7

by Branko Ajzele
June 2017
Intermediate to advanced
536 pages
9h 49m
English
Packt Publishing
Content preview from Mastering PHP 7

Using __callStatic()

The __callStatic() magic is nearly identical to the __call() method. Where the __call() method is bound to the object context, the __callStatic() method is bound to the static context, which means this method is triggered when invoking inaccessible methods via the scope resolution operator (::).

The method accepts two parameters as per the following synopsis:

public static mixed __callStatic (string $name, array $arguments)

Notice the use of the static access modifier in the method declaration that is required by the static context upon which this method operates. The following example demonstrates the use of the __callStatic() method in the static context:

<?phpclass User{ public static function __callStatic($name, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Upgrading to PHP 5

Upgrading to PHP 5

Adam Trachtenberg

Publisher Resources

ISBN: 9781785882814Supplemental Content