|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-19 21:49 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Feb 13 07:00:01 2026 UTC |
Description: ------------ It's possible to define a reference to a non-existent variable, which gets assigned in a loop (example 1). It's possble to define a reference to an existent key, too. Why is it not possible to define references to non existent respective reference defined keys? Reproduce code: --------------- // Example 1: $a = array (1, 2, 3); $b = &$value; foreach ($a as $value) { echo $b; } // Example 2: $a = array(array(1), array(2), array(3)); foreach ($a as $value) { $b = &$value[0]; echo $b; } // Example 3: $b = &$value[0]; foreach ($a as $value) { echo $b; } Expected result: ---------------- 123 123 123 Actual result: -------------- 123 123 (nullnullnull)