11.3. Objects and Classes
These functions return information about objects and classes.
string get_class(object variable)
The get_class function (Listing 11.72) returns the name of the class for the given object. From within a class method, you may use the __CLASS__ constant to get the same value. Note that PHP always returns class names in all lowercase.
Listing 11.72. get_class
<?php class animal { var $name; } $gus = new animal; print("Gus is of type " . get_class($gus) . "<br>\n"); ?> |
array get_class_methods(string class)array get_class_methods(object instance)
The get_class_methods function (Listing 11.73) returns an array of the names of the methods for the given class. You may give the class name or an instance of the class.
Listing ...
Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.