我嘗試打印創建新對象的類的名稱。 我得到這個代碼:如何獲得這個類的名字?
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 ();
的出放有:
new Class_A : are created
new Class_A : are created
爲什麼不new B : are created
new C : are created
?
我也試用getParentClass()
但它不工作謝謝!