爲什麼子類不在父類構造方法裏面?我應該做出什麼改變來獲得A,B,C的執行類的構造方法,以便當我運行$obj = new C();
PHP OOP繼承順序
<?php
class A
{
function A()
{
echo "I am the constructor of A. (Grand Parent)<br />\n";
}
}
class B extends A
{
function B()
{
echo "I am the constructor of B. (Parent)<br />\n";
}
}
class C extends B
{
function C()
{
echo "I am the constructor of C. (Child)<br />\n";
}
}
$obj = new C();
?>