note 83854 added to language.oop5

From: Date: Sun, 15 Jun 2008 14:32:00 +0000
Subject: note 83854 added to language.oop5
Groups: php.notes 
Request: Send a blank email to php-notes+get-140475@lists.php.net to get a copy of this message
Warning!!! using self, self in php mean about class in where you put self expression not child or child of child ..... abstract class cparent { public static function callme() { echo "from ".__CLASS__." ".__FUNCTION__."\n"; } public static function callme2() { echo "from ".__CLASS__." ".__FUNCTION__."\n"; return false; } public static function errorself() { if (self::callme2()){ echo "from ".__CLASS__." ".__FUNCTION__."\n"; } } } abstract class child1 extends cparent { public static function callme2() { //this function not called by parent. whyyyyyyy? echo "from ".__CLASS__." ".__FUNCTION__."\n"; return true; } public static function callme() { echo "from ".__CLASS__." ".__FUNCTION__."\n"; } } final class child2 extends child1 { public static function callme2() { //this function not called by parent. whyyyyyyy? echo "from ".__CLASS__." ".__FUNCTION__."\n"; return true; } public static function callme() { if (self::callme2()) { echo "from ".__CLASS__." ".__FUNCTION__."\n"; } } } //worked call_user_func(array("child2","callme")); //callme2 in class child2 not called call_user_func(array("child2","errorself")); solution final class child3 extends child1 { public static function errorself() { if (self::callme2()){ echo "from ".__CLASS__." ".__FUNCTION__."\n"; } } } ---- Server IP: 69.147.83.197 Probable Submitter: 221.132.208.114 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.php Edit -- https://master.php.net/note/edit/83854 Del: integrated -- https://master.php.net/note/delete/83854/integrated Del: useless -- https://master.php.net/note/delete/83854/useless Del: bad code -- https://master.php.net/note/delete/83854/bad+code Del: spam -- https://master.php.net/note/delete/83854/spam Del: non-english -- https://master.php.net/note/delete/83854/non-english Del: in docs -- https://master.php.net/note/delete/83854/in+docs Del: other reasons-- https://master.php.net/note/delete/83854 Reject -- https://master.php.net/note/reject/83854 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140475) next »