ID: 33513 Updated by: [EMAIL PROTECTED] Reported By: muhamad_zakaria at yahoo dot com -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: Windows XP Pro PHP Version: 5.0.3 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip Previous Comments: ------------------------------------------------------------------------ [2005-06-30 07:28:50] muhamad_zakaria at yahoo dot com 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 this bug report at http://bugs.php.net/?id=33513&edit=1