O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required