I try to print the name of the class that create the new object.
I got this code:
class Class_A
{
public function __construct()
{
echo "new ".__class__." : are created"."<br />";
}
}
class B extends Class_A
{
}
class C extends Class_A
{
}
$NewObject1= new B ( );
$NewObject2= new C ( );
the out put are:
new Class_A : are created
new Class_A : are created
why not new B : are created
new C : are created ?
I try also with getParentClass() but it is not working Thanks!
In this case you should write
echo "new ".get_called_class()." : are created"."<br />";You can take a look at http://www.php.net/manual/en/function.get-called-class.php