ID: 29378 User updated by: chernyshevsky at hotmail dot com Reported By: chernyshevsky at hotmail dot com Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 PHP Version: 5.0.0 New Comment:
I know the class doesn't have a member called 'cows'. That's what __get() and __set() is for after all. If I change the code to $O->cows = array("Betty", "Agnes", "Jeff"); $temp = $O->cows; foreach($temp as $cow) { echo "<div>$cow</div>"; } Now why should it fail just because the property access is through foreach()? Previous Comments: ------------------------------------------------------------------------ [2004-07-26 16:45:56] cysgwr_eryri at yahoo dot co dot uk Your 'Object' object doesn't have a 'cows' member variable. The "object with overloaded property access" that the warning is telling you about doesn't exist is this: $O->cows Which 'cows' are you referring to? ------------------------------------------------------------------------ [2004-07-25 17:47:50] chernyshevsky at hotmail dot com Description: ------------ Not sure if this is a duplicate of #28444. It's certainly related. Basically I was trying to loop through an array set earlier using __set and retrieve through __get. Simple enough it seems, but the engine died with an "Cannot access undefined property for object with overloaded property access" fatal error. Reproduce code: --------------- class Object { private $values; function __set($name, $value) { $this->values[$name] = $value; } function __get($name) { return $this->values[$name]; } } $O = new Object; $O->cows = array("Betty", "Agnes", "Jeff"); foreach($O->cows as $cow) { echo "<div>$cow</div>"; } Expected result: ---------------- Betty Agnes Jeff Actual result: -------------- Fatal error: Cannot access undefined property for object with overloaded property access ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29378&edit=1