note 81438 added to language.oop5.basic

From: Date: Thu, 28 Feb 2008 10:45:31 +0000
Subject: note 81438 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-136552@lists.php.net to get a copy of this message
Example#1 implies that get_class() will return the name of the object variable when in fact it returns the class name of which the object is an instance. So: <?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this is not defined.\n"; } } } class B { function bar() { A::foo(); } } $a = new A(); $a->foo(); A::foo(); $b = new B(); $b->bar(); B::bar(); ?> Will actually output: $this is defined (A) $this is not defined. $this is defined (B) $this is not defined. A subtle but critical difference. ---- Server IP: 87.124.64.96 Probable Submitter: 129.12.38.134 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php Edit -- https://master.php.net/note/edit/81438 Del: integrated -- https://master.php.net/note/delete/81438/integrated Del: useless -- https://master.php.net/note/delete/81438/useless Del: bad code -- https://master.php.net/note/delete/81438/bad+code Del: spam -- https://master.php.net/note/delete/81438/spam Del: non-english -- https://master.php.net/note/delete/81438/non-english Del: in docs -- https://master.php.net/note/delete/81438/in+docs Del: other reasons-- https://master.php.net/note/delete/81438 Reject -- https://master.php.net/note/reject/81438 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136552) next »