PHP: get_called_class vs get_class

get_called_class vs get_class

string get_called_class ( void ) //  Gets the name of the class the static method is called in. 
string get_class ([ object $object = NULL ] ) // Gets the name of the class of the given object. 


-------- get_called_class
class foo {
    static public function test() {
        var_dump(get_called_class());
    }
}

class bar extends foo {
}

foo::test(); // string(3) "foo"
bar::test(); // string(3) "bar"

--------- get_class

• get_class($this)
• get_class($bar)

class foo {
    function name()
    {
        echo "My name is " , get_class($this) , "\n";
    }
}

$bar = new foo(); // create an object
echo "Its name is " , get_class($bar) , "\n"; // external call		// Its name is foo
$bar->name(); // internal call						// My name is foo

----------

abstract class bar {
    public function __construct()
    {
        var_dump(get_class($this));
        var_dump(get_class());
    }
}

class foo extends bar {
}

new foo;

string(3) "foo"
string(3) "bar"