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

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

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by trycia.jones , 4 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;

Related Threads:

How to Use Php to Parse Json Data in 2025?
How to get length of an array in PHP ?
How to get the IP address of the client/user in PHP?
How can you get web browser’s details using PHP?
How to get number of days between two given dates using PHP ?
What is difference Between PHP 5 and 7?