| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2005-08-13 13:58 UTC] ondrej at sury dot org
 Description:
------------
func_get_arg() can be used as argument to function only once.
Reproduce code:
---------------
<?php
function doTitle($a = NULL, $b = NULL) {
  print "doTitle: $a, $b\n";
}
function doHead() {
  doTitle(func_get_arg(0));
  doTitle(func_get_arg(1));
  doTitle(func_get_arg(0), "3");
  doTitle(func_get_arg(0), func_get_arg(1));
}
doHead("1", "2");
?>
Expected result:
----------------
doTitle: 1,
doTitle: 2,
doTitle: 1, 3
doTitle: 1, 2
Actual result:
--------------
doTitle: 1,
doTitle: 2,
doTitle: 1, 3
Fatal error: func_get_arg(): Can't be used as a function parameter in /tmp/func_get_arg.php on line 11
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
Dmitry, this script should fail for all of those: <?php function doTitle($a = NULL, $b = NULL) { print "doTitle: $a, $b\n"; } function doHead() { doTitle(func_num_args()); doTitle(func_get_arg(0)); doTitle(func_get_args()); } doHead("1", "2");