Controlling Anonymous Class Usage

Learn about the anonymous classes introduced in PHP 8.

Enhancements in anonymous classes in PHP 8

Anonymous classes, by their very definition, do not have a name. However, for the purposes of information, PHP informational functions such as var_dump(), var_ export(), get_class(), and other classes in the Reflection extension will report the anonymous class simply as class@anonymous. However, when an anonymous class extends another class or implements an interface, it might be of some use to have PHP informational functions reflect this fact.

Get hands-on with 1400+ tech skills courses.