PHP 8.5.0 Alpha 1 available for testing

Voting

: seven minus four?
(Example: nine)

The Note You're Voting On

Hayley Watson
7 years ago
Although you can call a class's static methods from an instance of the class as though they were object instance methods, it's nice to know that, since classes are represented in PHP code by their names as strings, the same thing goes for the return value of get_class():

<?php
$t
->Faculty();
SomeClass::Faculty(); // $t instanceof SomeClass
"SomeClass"::Faculty();
get_class($t)::Faculty();
?>

The first is legitimate, but the last makes it clear to someone reading it that Faculty() is a static method (because the name of the method certainly doesn't).

<< Back to user notes page

To Top