note 44618 deleted from migration5.oop by nlopess

From: Date: Fri, 08 Oct 2004 17:33:41 +0000
Subject: note 44618 deleted from migration5.oop by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78188@lists.php.net to get a copy of this message
Note Submitter: rbates at delete_this_part dot artbeats dot com ---- The __get() function will not be called recersively. In other words, __get() will not be used if you attempt to retrieve an undefined property from $this while currently in __get(). Here is an example: <?php class Greater { function __get($name) { if ($name == "hi") { return $this->hello; } else if ($name == "hello") { return "Hello, World!"; } return "Unknown: $name"; } } $greater = new Greater; // This appropriately prints "Hello, World!" echo($greater->hello); // This reports "Notice: Undefined property: Greater::$hello // in /path/to/file/greater.php on line 8" echo($greater->hi); ?> I am assuming this is to stop infinite loops, but it is also annoying when done intentionally.

« previous php.notes (#78188) next »