|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31974 func_get_args() does not work when variables have "_" in the middle of the name
Submitted: 2005-02-14 20:23 UTC Modified: 2005-02-15 01:50 UTC
From: pinhinha at gmail dot com Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 5.0.3 OS: LINUX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pinhinha at gmail dot com
New email:
PHP Version: OS:


 [2005-02-14 20:23 UTC] pinhinha at gmail dot com
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() {
  foreach (func_get_args() as $var) {     
  if (isset($GLOBALS[$var]))
  else exit("<b>Error</b>: var '<b>$var</b>' is not set.");
  return $new_array;
$domain_name = "";
$visit_date = date("Y-m-d");
$array = do_array("domain_name", "visit_date");

Expected result:
$array = ("domain_name" => "",
          "visit_date" => "2005-02-14"

Actual result:
Error: var 'domain_name' is not set.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-15 01:41 UTC] shadda at gmail dot com
You do realise, array_combine() does exactly that, right? Not to mention that even were you using php4 there are several user comments throughought that show you how to accomplish this very thing (And if I recall, There's a PEAR_COMPAT package that contains this functionality.)
 [2005-02-15 01:42 UTC] shadda at gmail dot com
Got cut off.

The code also works fine in my php5.0.3.
 [2005-02-15 01:42 UTC] pinhinha at gmail dot com
Miss PHP4 version, its 4.3.10
 [2005-02-15 01:50 UTC] pinhinha at gmail dot com
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 21:01:29 2024 UTC