From:
Operating system: freebsd, osx
PHP version: 5.3.5
Package: Reflection related
Bug Type: Bug
Bug description:Access variable in class dynamicaly
Description:
------------
It seems, that when I read a class variable with the varname in a string,
it
works, but writing in the same way doesn't
Test script:
---------------
<?
class XXX
{
private $cisupport = Array( 1 );
private $cicoordinator = Array();
function support() {
$x = 'cisupport';
print( "Request support static:\n");
print_r( $this->cisupport );
print( "Request support dynamic:\n");
print_r( $this->$x );
}
function coordinator() {
$x = 'cicoordinator';
print( "Set coordinator static:\n");
$this->cicoordinator[ 1 ] = 12;
print_r( $this->cicoordinator );
print( "Set coordinator dynamic:\n");
$this->${x}[ 1 ] = 9999;
print_r( $this->${x} );
}
}
$x = new XXX;
$x->support();
$x->coordinator();
?>
Expected result:
----------------
Request support static:
Array
(
[0] => 1
)
Request support dynamic:
Array
(
[0] => 1
)
Set coordinator static:
Array
(
[1] => 12
)
Set coordinator dynamic:
Array
(
[1] => 9999
)
Actual result:
--------------
Request support static:
Array
(
[0] => 1
)
Request support dynamic:
Array
(
[0] => 1
)
Set coordinator static:
Array
(
[1] => 12
)
Set coordinator dynamic:
Array
(
[1] => 12
)
--
Edit bug report at http://bugs.php.net/bug.php?id=53720&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53720&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53720&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53720&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53720&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53720&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53720&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53720&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53720&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53720&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53720&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53720&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53720&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53720&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53720&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53720&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53720&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53720&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53720&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53720&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53720&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53720&r=mysqlcfg