|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-06-29 23:48 UTC] jlim at natsoft dot com
Description:
------------
The following script below fails (missing $k).
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
echo PHP_VERSION."<br>";
print_r($_GET);
foreach($_GET as $k=>$v) {
global $$k;
print " ($k=>$v) ";
$$k = $v;
}
?>
Expected result:
----------------
5.0.0b1
Array ( [a] => 1 [b] => 2 [c] => 3 ) (a=>1) (b=>2) (c=>3)
Actual result:
--------------
5.0.0b1
Array ( [a] => 1 [b] => 2 [c] => 3 ) (=>1) (=>2) (=>3)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
<?php $arr = array('a' => 1, 'b' => 2, 'c' => 3); echo PHP_VERSION."<br>"; print_r($arr); foreach($arr as $k=>$v) { global $$k; // comment this out and it works in PHP 5 too.. print " ($k=>$v) "; $$k = $v; }