#24790 [Opn->Csd]: Array access broken with class variables
ID: 24790
Updated by: zeev@php.net
Reported By: proton at fangen dot net
-Status: Open
+Status: Closed
Bug Type: Class/Object related
Operating System: Windows XP Home
PHP Version: 5CVS-2003-07-24 (dev)
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-07-24 05:20:18] proton at fangen dot net
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 this bug report at http://bugs.php.net/?id=24790&edit=1
Thread (2 messages)