How to get no of arguments passed to a PHP Function?

by dion.waelchi , in category: Technology , 3 years ago

How to get no of arguments passed to a PHP Function?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by trycia.jones , 3 years ago

func_get_args() function is used to get number of arguments passed in a PHP function.


Sample Usage:

1
2
3
4
5
6
function foo() {
   return  func_get_args();
}
echo foo(1,5,7,3);//output 4;
echo foo(a,b);//output 2;
echo foo();//output 0;