#31974 [NEW]: func_get_args() does not work when variables have "_" in the middle of the name
| From: | pinhinha at gmail dot com | Date: | Mon, 14 Feb 2005 19:23:31 +0000 |
| Subject: | #31974 [NEW]: func_get_args() does not work when variables have "_" in the middle of the name | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-74049@lists.php.net to get a copy of this message | ||
From: pinhinha at gmail dot com
Operating system: LINUX
PHP version: 5.0.3
PHP Bug Type: *Programming Data Structures
Bug description: func_get_args() does not work when variables have "_" in the middle of
the name
Description:
------------
Builds an associative array using value of previous defined vars.
It works on PHP 4.0.10
It doens't work on PHP 5.0.3
If the var names don't have "_" (underscore) in the name it works on PHP4
AND PHP5.
Reproduce code:
---------------
function do_array() {
$new_array=array();
foreach (func_get_args() as $var) {
if (isset($GLOBALS[$var]))
$new_array[$var]=$GLOBALS[$var];
else exit("<b>Error</b>: var '<b>$var</b>' is not
set.");
}
return $new_array;
}
$domain_name = "php.net";
$visit_date = date("Y-m-d");
$array = do_array("domain_name", "visit_date");
Expected result:
----------------
$array = ("domain_name" => "php.net",
"visit_date" => "2005-02-14"
);
Actual result:
--------------
Error: var 'domain_name' is not set.
--
Edit bug report at http://bugs.php.net/?id=31974&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31974&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31974&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31974&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31974&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31974&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31974&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31974&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31974&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31974&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31974&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31974&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31974&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31974&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31974&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31974&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31974&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31974&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31974&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31974&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31974&r=mysqlcfg