1
<?php
class parentClass {
function myChild() {
echo 'Child Class Name: '.__CLASS__;
}
}
class childClass extends parentClass {
}
$childClassObj = new childClass;
$childClassObj->myChild();
Child Class Name: parentClass
其實,我期待的輸出
Child Class Name: childClass
我應該怎麼做才能輸出?
得到答案http://stackoverflow.com/questions/9577984/how-to-get-child-class -name-from-parent-class –
你可以在每個孩子中重寫'myChild',但我想這不是你想要的 –