#33512 [NEW]: Encountered error on using magic method (Overload Section)

From: Date: Thu, 30 Jun 2005 03:12:03 +0000
Subject: #33512 [NEW]: Encountered error on using magic method (Overload Section)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81186@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: Compile Failure Bug description: Encountered error on using magic method (Overload Section) 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 bug report at http://bugs.php.net/?id=33512&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33512&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33512&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33512&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33512&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33512&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33512&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33512&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33512&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33512&r=support Expected behavior: http://bugs.php.net/fix.php?id=33512&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33512&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33512&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33512&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33512&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33512&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33512&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33512&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33512&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33512&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33512&r=mysqlcfg

« previous php.bugs (#81186) next »