From:             mk at peytz dot dk
Operating system: Linux
PHP version:      5.0.3
PHP Bug Type:     Zend Engine 2 problem
Bug description:  __set acts unexpected with variable variables

Description:
------------
When setting variable variable values on a instance of a class with an
overloading __set function changing another instance variable goes wrong.

(I'm reporting it for version 5.0.3 because the current cvs snapshot would
not compile.)

Reproduce code:
---------------
http://dev.peytz.dk/~mk/setter.php
<?php
class Setter
{
    private $_fields = array(); // the data fields
    private $_changedFields = array(); // list of changed fields

    function __set($name, $value)
    {
        // set value
        $this->_fields[$name] = $value;
        // add to list of changed fields
        $this->_changedFields[] = $name;
    }
}
$foo = new Setter;
$foo->a = 1;
$var = "b";
$foo->$var = 2;
var_export($foo);
?>

Expected result:
----------------
class Setter {
  private $_fields = 
  array (
    'a' => 1,
    'b' => 2,
  );
  private $_changedFields = 
  array (
    0 => 'a',
    1 => 'b',
  );
}

Actual result:
--------------
class Setter {
  private $_fields = 
  array (
    'a' => 1,
    'b' => 2,
  );
  private $_changedFields = 
  array (
    0 => 'a',
    1 => '���',
  );
}

-- 
Edit bug report at http://bugs.php.net/?id=32334&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32334&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32334&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32334&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32334&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32334&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32334&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32334&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32334&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32334&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32334&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32334&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32334&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32334&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32334&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32334&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32334&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32334&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32334&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32334&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32334&r=mysqlcfg

Reply via email to