|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-03-10 11:58 UTC] takayana at egate1 dot com
Description: ------------ By a Session variable Operation by PHP4.3.10 carries out different operation from a low-ranking version. When the following 6 files are created and test_web1.php is performed, in the case of a low rank version (for example, PHP4.3.9) $_SESSION '[data]' Arrangement id value 31, 1, 2, 3, 4, and 5 ... Although set to 20, in the case of PHP4.3.10, it is. 31, 1, 2, 3, 3, and 5 ... It will be set to 20. Reproduce code: --------------- http://www.egate1.com/docs/.tmp/code.txt PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 23 00:00:01 2025 UTC |
Here's the shortest possible example script I came up with, which does exactly same as your multiple scripts plus shows what really happens: <?php class data {var $f;} session_start(); $phase = isset($_GET['phase']) ? $_GET['phase'] : 1; switch ($phase) { case 1: $_SESSION['foo'][0] = new data; $_SESSION['foo'][0]->f = 1; $_SESSION['foo'][1] = new data; $_SESSION['foo'][1]->f = 2; header("Location: test_web.php?phase=2"); exit(1); break; case 2: $_SESSION['bar'] = new data; $_SESSION['bar']->f = 3; header("Location: test_web.php?phase=3"); exit(1); break; case 3: $_SESSION['foo'][0] = $_SESSION['bar']; // Here be bug header("Location: test_web.php?phase=4"); exit(1); break; case 4: $_SESSION['bar'] = 'foo'; header("Location: test_web.php?phase=5"); exit(1); break; case 5: echo '<pre>'; var_dump($_SESSION); echo '</pre>'; break; } ?> Output is this: array(2) { ["foo"]=> array(2) { [0]=> &string(3) "foo" [1]=> object(data)(1) { ["f"]=> int(2) } } ["bar"]=> &string(3) "foo" } Result: ['bar'] became a reference to ['foo'][0] (Does NOT happen when using arrays instead of object)