Press "Enter" to skip to content

How to count number of variable parameter in a function – PHP

0

Sometime while working with function in php, we want to know that how many argument is passing in a function or a variable parameter.

For solving this situation we need to count the variable parameter by this function func_num_args() – it will return the number of argument pass to this function.

Example:-

<?php
function abc(){
  echo "Number of argument ".func_num_args();
}
abc(2,5,"a");//Number of argument 3
?>

func_get_args — This function returns an array comprising a function’s argument list, it will be used to get the array of arguments.

How to export a query result in excel CSV from MySQL PHPMyAdmin
What is explode and implode in PHP?