Thursday, April 1, 2010

Identifying the number of parameters passed to a function?

Answer:

We can use - func_num_args()

This function can return the number of argument passed to the function

small example

function test()
{
$numargs = func_num_args();
echo
"Number of passed arguments: $numargs\n";
}

test(1, 2, 3);

Output
======
Number of passed arguments: 3

No comments:

Post a Comment