ID: 33512
Updated by: [EMAIL PROTECTED]
Reported By: muhamad_zakaria at yahoo dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows XP Pro
PHP Version: 5.1.0-dev
New Comment:
PHP hasn't magic callback to unset overloaded properties.
This is the reason why unset($SomeObj->Virtual1) doesn't work.
Previous Comments:
------------------------------------------------------------------------
[2005-07-04 10:38:12] muhamad_zakaria at yahoo dot com
We have tried from the feedback (tony2001), and the raised error is no
longer.
But we have another experiences while using 'unset' statement, such as
below:
// we will try to unset these variables
unset($SomeObj->RealVar1);
unset($SomeObj->{'RealVar'.(3)});
//the lines below will catch by '__get' magic method since these
variables are unavailable anymore
print $SomeObj->RealVar1."\n";
print $SomeObj->{'RealVar'.(3)}."\n";
// now we will try to unset these variables
unset($SomeObj->Virtual1);
unset($SomeObj->{'Virtual'.(3)});
//but, these variables are still available??? eventhough they're
"unset"-ed
print $SomeObj->Virtual1."\n";
print $SomeObj->{'Virtual'.(3)}."\n";
------------------------------------------------------------------------
[2005-06-30 10:23:37] [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 05:12:01] muhamad_zakaria at yahoo dot com
Description:
------------
When we used virtual variables exploiting __set overload method, we
encountered errors.
Reproduce code:
---------------
class TheObj {
public $RealVar1, $RealVar2, $RealVar3, $RealVar4;
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->RealVar1 = 'somevalue';
$SomeObj->{'RealVar2'} = 'othervalue';
$SomeObj->{'RealVar'.(3)} = 'othervaluetoo';
$SomeObj->{'RealVar'.'4'} = 'anothervalue';
// this will fine too
$SomeObj->Virtual1 = 'somevalue';
$SomeObj->{'Virtual2'} = 'othervalue';
// it's can't be used since this will encounter error
$SomeObj->{'Virtual'.(3)} = 'othervaluetoo';
$SomeObj->{'Virtual'.'4'} = 'anothervalue';
// but this will fine, ofcourse
$SomeObj->Var['Virtual'.(3)] = 'othervaluetoo';
$SomeObj->Var['Virtual'.'4'] = 'anothervalue';
Expected result:
----------------
No error when we use below lines:
<?php
$SomeObj->{'Virtual'.(3)} = 'othervaluetoo';
$SomeObj->{'Virtual'.'4'} = 'anothervalue';
?>
because this should applied fine as we did at "RealVarX" treatments.
Actual result:
--------------
Encountered error raises by php.exe
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33512&edit=1