#33513 [NEW]: Fatal error encountered on using Magic method (Overload Section)

From: Date: Thu, 30 Jun 2005 05:28:51 +0000
Subject: #33513 [NEW]: Fatal error encountered on using Magic method (Overload Section)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81188@lists.php.net to get a copy of this message
From: muhamad_zakaria at yahoo dot com Operating system: Windows XP Pro PHP version: 5.0.3 PHP Bug Type: Scripting Engine problem Bug description: Fatal error encountered on using Magic method (Overload Section) Description: ------------ Summary: -------- When we used virtual variables exploiting __get magic method, we received "Fatal error" message. We have experienced using 'while' loop statement rather than 'foreach' for the example, but it result same fatal error. Reproduce code: --------------- class TheObj { public $RealMatArr; public $Var = array(); function __set($var, $val) { $this->Var[$var] = $val; } function __get($var) { if(isset($this->Var[$var])) return $this->Var[$var]; else return -1; } } $SomeObj = new TheObj; // this will fine $SomeObj->RealMatArr = array( "One" => array("11", "12", "13"), "Two" => array("21", "22", "23"), "Three" => array("31", "32", "33")); $SomeObj->VirtualMatArr = array( "One" => array("11", "12", "13"), "Two" => array("21", "22", "23"), "Three" => array("31", "32", "33")); // this will fine too foreach($SomeObj->RealMatArr as $indX => $dataX) { foreach($dataX as $indY => $dataY) { print "RealMatArr[$indX][$indY] = $dataY\n"; } } // this will encounter 'Fatal error' message foreach($SomeObj->VirtualMatArr as $indX => $dataX) { foreach($dataX as $indY => $dataY) { print "VirtualMatArr[$indX][$indY] = $dataY\n"; } } // but the fatal error will no longer when we modified the lines below: $arrval = $SomeObj->VirtualMatArr; foreach($arrval as $indX => $dataX) { foreach($dataX as $indY => $dataY) { print "VirtualMatArr[$indX][$indY] = $dataY\n"; } } Expected result: ---------------- RealMatArr[One][0] = 11 RealMatArr[One][1] = 12 RealMatArr[One][2] = 13 RealMatArr[Two][0] = 21 RealMatArr[Two][1] = 22 RealMatArr[Two][2] = 23 RealMatArr[Three][0] = 31 RealMatArr[Three][1] = 32 RealMatArr[Three][2] = 33 VirtualMatArr[One][0] = 11 VirtualMatArr[One][1] = 12 VirtualMatArr[One][2] = 13 VirtualMatArr[Two][0] = 21 VirtualMatArr[Two][1] = 22 VirtualMatArr[Two][2] = 23 VirtualMatArr[Three][0] = 31 VirtualMatArr[Three][1] = 32 VirtualMatArr[Three][2] = 33 Actual result: -------------- RealMatArr[One][0] = 11 RealMatArr[One][1] = 12 RealMatArr[One][2] = 13 RealMatArr[Two][0] = 21 RealMatArr[Two][1] = 22 RealMatArr[Two][2] = 23 RealMatArr[Three][0] = 31 RealMatArr[Three][1] = 32 RealMatArr[Three][2] = 33 Fatal error: Cannot access undefined property for object with overloaded property access in e:\www\Project1\latihan\obj2.php on line 37 -- Edit bug report at http://bugs.php.net/?id=33513&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33513&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33513&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33513&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33513&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33513&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33513&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33513&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33513&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33513&r=support Expected behavior: http://bugs.php.net/fix.php?id=33513&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33513&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33513&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33513&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33513&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33513&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33513&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33513&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33513&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33513&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33513&r=mysqlcfg

« previous php.bugs (#81188) next »