|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-16 12:55 UTC] tony2001@php.net
[2005-06-16 16:23 UTC] luca dot fabbro at procne dot it
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 15:00:01 2025 UTC |
Description: ------------ Seems that once you've declared a pointer to one of the items in session superglobal any other assignment of a variable to that session item is alwayys treated as a pointer. Tested on various versions of php 4.3 till 4.3.1 Register globals are OFF php 5.0.4 having same error Reproduce code: --------------- session_start(); for ($i = 0; $i < 2; $i++) { $_SESSION['storage'][$i] = array('items'=>$i); } $items = count($_SESSION['storage']); for ($i = 0; $i < $items; $i++) { $pointer = &$_SESSION['storage'][$i]; // unset($pointer); // Uncomment me to let me work properly } $gitems = $_SESSION['storage']; foreach ($gitems as $key=>$val) { $gitems[$key]['foo'] = time(); } Expected result: ---------------- $_SESSION = Array ( [storage] => Array ( [0] => Array ( [items] => 0 ) [1] => Array ( [items] => 1 ) ) ) Actual result: -------------- $_SESSION = Array ( [storage] => Array ( [0] => Array ( [items] => 0 [foo] => 1118913576 ) [1] => Array ( [items] => 1 [foo] => 1118913576 ) ) )