#33512 [Opn->Fbk]: Encountered error on using magic method (Overload Section)
| From: | tony2001@php.net | Date: | Thu, 30 Jun 2005 08:23:38 +0000 |
| Subject: | #33512 [Opn->Fbk]: Encountered error on using magic method (Overload Section) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81199@lists.php.net to get a copy of this message | ||
ID: 33512
Updated by: tony2001@php.net
Reported By: muhamad_zakaria at yahoo dot com
-Status: Open
+Status: Feedback
Bug Type: Compile Failure
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 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