|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-24 08:15 UTC] zeev@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 09:00:02 2025 UTC |
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