php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #37155 func_get_args feature change request
Submitted: 2006-04-21 14:49 UTC Modified: 2018-05-05 18:06 UTC
From: akari dot no dot ryu at whitedragons dot org Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.1.2 OS: Mac OS/X
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: akari dot no dot ryu at whitedragons dot org
New email:
PHP Version: OS:

 

 [2006-04-21 14:49 UTC] akari dot no dot ryu at whitedragons dot org
Description:
------------
Is it possible to make func_get_args return a hashed array instead of a numeric one? Possibly by adding an argument to it.

Reproduce code:
---------------
function changeProfileDetails($userId, $password, $surname){
 echo "<!--\n";
 foreach(func_get_args() as $key=>$val){
   echo "$key=>$val";
 }
 echo "-->";
}

changeProfileDetails(1, "test", "whoCares");

Expected result:
----------------
<!--
  userId=>1
  password=>'test'
  surname=>'whoCares'
-->

Actual result:
--------------
<!--
  0=>1
  1=>'test'
  2=>'whoCares'
-->

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-05 18:06 UTC] requinix@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2018-05-05 18:06 UTC] requinix@php.net
Old request is old.

I don't see a good reason for this. If it's for debugging then you can look up parameter names with Reflection. If it's for convenience (eg, SQL column names) then I would recommend against it and you should construct the array manually.
If there's still any interest in making this happen then we can reopen.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 03:01:28 2024 UTC