self

<?php 
class MyObject {
    function myBaseMethod() {
        echo "I am declared in MyObject\n";
    }
}
class MyOtherObject extends MyObject { function myExtendedMethod() { echo "myExtendedMethod is declared in MyOtherObject\n"; self::myBaseMethod(); } }
MyOtherObject
::myExtendedMethod(); //myExtendedMethod is declared in MyOtherObject //I am declared in MyObject

 

posted on 2015-07-15 18:12  yhdsir  阅读(101)  评论(0编辑  收藏  举报

导航