|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-21 11:55 UTC] iliaa@php.net
[2004-01-23 17:45 UTC] kavol at email dot cz
[2004-01-24 23:52 UTC] sniper@php.net
[2004-01-25 15:09 UTC] kavol at email dot cz
[2004-01-28 08:01 UTC] kavol at email dot cz
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 27 03:00:01 2025 UTC |
Description: ------------ after extract()ing an array containing a "key" => "data" with "key" being the same name as in $_SESSION, not only $key = "data", but the content of $_SESSION["key"] gets overwritten with "data" too Reproduce code: --------------- $jazyky = array (array ("jazyk" => "Če?tina", "kod" => "cs", "jak" => "česky"), array ("jazyk" => "English", "kod" => "en", "jak" => "English")); $_SESSION["jazyk"] = "cs"; $jazyk = $_SESSION["jazyk"]; // this IS NOT assigment by reference ! (from manual: "the assignment copies the original variable to the new one") echo $_SESSION["jazyk"]; foreach ($jazyky as $j) { extract ($j); echo "<a href='?jazyk=$kod'><img alt=\"$jak\" class=\"vlajka\" src=\"images/flag-$kod.png\"> $jazyk</a><br>"; echo $_SESSION["jazyk"]; }; $jazyk = $_SESSION["jazyk"]; // this is the problem - I wanted to restore the previosly overwritten $jazyk but I found $_SESSION["jazyk"] to be overwritten too! Expected result: ---------------- cs <a href='?jazyk=cs'><img alt="česky" class="vlajka" src="images/flag-cs.png"> Če?tina</a><br> cs <a href='?jazyk=en'><img alt="English" class="vlajka" src="images/flag-en.png"> English</a><br> cs Actual result: -------------- cs <a href='?jazyk=cs'><img alt="česky" class="vlajka" src="images/flag-cs.png"> Če?tina</a><br> Če?tina <a href='?jazyk=en'><img alt="English" class="vlajka" src="images/flag-en.png"> English</a><br> English