func_num_args

int func_num_args(void) 

Gets the number of arguments passed to a function.

Returns:

The number of arguments passed to a user function; -1 if func_num_args() is called in global scope

Description:

func_num_args() returns the number of arguments that have been passed to a user-defined function. It’s most often used in conjunction with func_get_arg() and func_get_args() to ensure that the right number of arguments have been passed to a function.

Availability:

UNIX, Windows

Version:

4.0b4+

See also:

func_get_arg() 
func_get_args() 

Examples:

Demonstrate how func_num_args() works
 <pre> <?php function demo () { $num_args = func_num_args(); print "The function was passed $num_args argument(s).\n"; } demo (); demo ('A single argument'); ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.