Advertisement
MrLore

PHP: Infinite arguments

Nov 9th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1.         $infArgs = function($args)
  2.         {
  3.             echo "You have supplied " . func_num_args() . " arguments:<br />";
  4.             $actualArgs = func_get_args();
  5.             for($i = 1; $i <= count($actualArgs); $i++)
  6.             {
  7.                 echo "Parameter $i: " . $actualArgs[$i - 1] . "<br />";
  8.             }//End for
  9.         echo "...also $args.";    //Equal to func_get_args()[0]
  10.         };//End infArgs()
  11.        
  12.         $infArgs('one', 'two', 'three', 'four');                //Counts 4
  13.         $infArgs('one', 'two', 'three', 'four', 'five', 'six', 'seven');    //Counts 7
  14.         $infArgs();                             //Error: not enough params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement