Wednesday, 7 April 2010

How do I find out the number of parameters passed into function?

PHP provides a function name func_num_args() which returns the number of parameters passed in.

for example:

<?phpfunction foo()
{
    
$numargs func_num_args();
    echo 
"Number of arguments: $numargs\n";
}
foo(123);    // Prints 'Number of arguments: 3'?>


Cheers!

No comments:

Post a Comment