Menu Home

get_called_class

osbo.com | PHP | Functions | get_called_class

The "Late Static Binding" class name

Syntax

get_called_class ( void ) : string

Return

Returns the class name. Returns FALSE if called from outside a class.

Examples

<?

class myclass1
{
    static public function myfunction()
    {
        $return = get_called_class();

        echo $return . PHP_EOL;
    }
}
class myclass2 extends myclass1
{
}

myclass1::myfunction();
myclass2::myfunction();

?>
myclass1
myclass2

PHP