note 81438 rejected from language.oop5.basic by felipe

From: Date: Mon, 24 Mar 2008 22:15:50 +0000
Subject: note 81438 rejected from language.oop5.basic by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137480@lists.php.net to get a copy of this message
Note Submitter: msaspence at gmail dot com ---- 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.

« previous php.notes (#137480) next »