From:             proton at fangen dot net
Operating system: Windows XP Home
PHP version:      5CVS-2003-07-24 (dev)
PHP Bug Type:     Class/Object related
Bug description:  Array access broken with class variables

Description:
------------
Accessing $this->values['foo']['bar']['2'] does not work like expected
inside a class while accessing $values['foo']['bar']['2'] does work like
expected.. It's a little hard to explain so I'll just let the code speak
for itself:

Reproduce code:
---------------
$values = array(
        'foo' => array(
                'bar' => array(
                        '2' => 'whatever'
                )
        )
);

var_dump($values['foo']['bar']['2']); // This works as expected

class MyClass
{
        var $values = array(
                'foo' => array(
                        'bar' => array(
                                '2' => 'whatever'
                        )
                )
        );

        function __construct()
        {
                var_dump($this->values['foo']['bar']['2']); // This doesn't...
                var_dump($this->values['foo']['bar'][2]); // This doesn't either...
        }
}

$c = new MyClass;

Expected result:
----------------
string(8) "whatever"
string(8) "whatever" 
string(8) "whatever" 

Actual result:
--------------
string(8) "whatever" 
Notice: Undefined offset: 2 in myfile.php on line 25
NULL 
Notice: Undefined offset: 2 in myfile.php on line 26
NULL 

-- 
Edit bug report at http://bugs.php.net/?id=24790&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24790&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24790&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24790&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24790&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24790&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24790&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24790&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24790&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24790&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24790&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24790&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24790&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24790&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24790&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24790&r=gnused

Reply via email to