ID: 33513
User updated by: muhamad_zakaria at yahoo dot com
Reported By: muhamad_zakaria at yahoo dot com
-Status: Feedback
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: Windows XP Pro
-PHP Version: 5.0.3
+PHP Version: 5.1.0-dev
New Comment:
Summary:
--------
The Fatal error is no longer when we tried from the feedback
(tony2001).
But we have another experiences while we applied 'unset' statement such
as below:
// we will try unset these variables, and it's work
unset($SomeObj->RealMatArr["Two"]);
unset($SomeObj->RealMatArr["Three"][1]);
// now we will try unset the whole variable array below
unset($SomeObj->RealMatArr);
// ofcourse, this will raises warning since the variable is no longer
available (it's work)
foreach($SomeObj->RealMatArr as $indX => $dataX) {
foreach($dataX as $indY => $dataY) {
print "RealMatArr[$indX][$indY] = $dataY\n";
}
}
// then we will try unset these variables, and it's work
unset($SomeObj->VirtualMatArr["Two"]);
unset($SomeObj->VirtualMatArr["Three"][1]);
// then next we will unset the whole of this variable array as below
unset($SomeObj->VirtualMatArr);
// but, this will raises no warning as we never unset it before???
reset($SomeObj->VirtualMatArr);
while(list($indX, $dataX) = each($SomeObj->VirtualMatArr)) {
while(list($indY, $dataY) = each($dataX)) {
print "VirtualMatArr[$indX][$indY] = $dataY\n";
}
}
We have no knowledge about the reason, but maybe the reason is the
same as the posted feedback (dmitry) at
http://bugs.php.net/bug.php?id=33512.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2005-06-30 10:23:34] [EMAIL PROTECTED]
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
------------------------------------------------------------------------
[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