ID: 25996 User updated by: hongnk at hotmail dot com Reported By: hongnk at hotmail dot com Status: Bogus Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS, 4CVS (2004-03-15) New Comment:
Why is this bug closed? I din't see anywhere in the comment of "unknown" that he tried to use an undefined index. And I suspect that his example is incorrect, because var_dump($element) after assigning return NULL. Previous Comments: ------------------------------------------------------------------------ [2004-04-07 05:49:24] [EMAIL PROTECTED] see above ------------------------------------------------------------------------ [2004-03-30 10:00:25] unknown at simplemachines dot org I would like to say that this is a feature of PHP, and that it is working as intended. Why? This simple snippet explains it all: <?php $array = array( 'inner' => array( 'another' => array() ) ); $element = &$array['inner']['another'][]; $element['test'] = 1; $element['test2'] = 4; ?> This functionality makes sense, at least in this context. You're creating a new element, and getting it with the element reference. This can make things easier and possibly faster to work with - instead of this: <?php $array = array( 'inner' => array( 'another' => array() ) ); $element['test'] = 1; $element['test2'] = 4; $array['inner']['another'][] = $element; ?> Which is basically the same thing - just in a different order. I don't think this is a bug, and if it were to be fixed it would cause a lot of scripts - including ones I've written - to start generating notices when they shouldn't be. (as I always try to write notice-less code.) -[Unknown] ------------------------------------------------------------------------ [2003-10-29 14:13:04] [EMAIL PROTECTED] Related to bug #26030 ------------------------------------------------------------------------ [2003-10-26 21:33:23] hongnk at hotmail dot com Description: ------------ Accessing array with uninitialized index will normally trigger error: $a=array(); $b=$a['unknown']; => undefined index error but if I assign by reference: $b=&$a['unknown']; then PHP no longer throw error. (The same goes for assigning undefined property to an object.) This makes it difficult to debug scripts. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25996&edit=1