Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

func_num_args(3) [php man page]

FUNC_NUM_ARGS(3)							 1							  FUNC_NUM_ARGS(3)

func_num_args - Returns the number of arguments passed to the function

SYNOPSIS
int func_num_args (void ) DESCRIPTION
Gets the number of arguments passed to the function. This function may be used in conjunction with func_get_arg(3) and func_get_args(3) to allow user-defined functions to accept variable- length argument lists. RETURN VALUES
Returns the number of arguments passed into the current user-defined function. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function can now be used in parameter | | | lists. | | | | | 5.3.0 | | | | | | | If this function is called from the outermost | | | scope of a file which has been included by call- | | | ing include(3) or require(3) from within a func- | | | tion in the calling file, it now generates a | | | warning and returns -1. | | | | +--------+---------------------------------------------------+ ERRORS
/EXCEPTIONS Generates a warning if called from outside of a user-defined function. EXAMPLES
Example #1 func_num_args(3) example <?php function foo() { $numargs = func_num_args(); echo "Number of arguments: $numargs "; } foo(1, 2, 3); ?> The above example will output: Number of arguments: 3 Example #2 func_num_args(3) example before and after PHP 5.3 test.php <?php function foo() { include './fna.php'; } foo('First arg', 'Second arg'); ?> fna.php <?php $num_args = func_num_args(); var_export($num_args); ?> Output previous to PHP 5.3: 2 Output in PHP 5.3 and later will be something similar to: Warning: func_num_args(): Called from the global scope - no function context in /home/torben/Desktop/code/ml/fna.php on line 3 -1 NOTES
Note Because this function depends on the current scope to determine parameter details, it cannot be used as a function parameter in ver- sions prior to 5.3.0. If this value must be passed, the results should be assigned to a variable, and that variable should be passed. SEE ALSO
... syntax in PHP 5.6+, func_get_arg(3), func_get_args(3), ReflectionFunctionAbstract::getNumberOfParameters. PHP Documentation Group FUNC_NUM_ARGS(3)

Check Out this Related Man Page

DEBUG_PRINT_BACKTRACE(3)						 1						  DEBUG_PRINT_BACKTRACE(3)

debug_print_backtrace - Prints a backtrace

SYNOPSIS
void debug_print_backtrace ([int $options], [int $limit]) DESCRIPTION
debug_print_backtrace(3) prints a PHP backtrace. It prints the function calls, included/required files and eval(3)ed stuff. PARAMETERS
o $options - As of 5.3.6, this parameter is a bitmask for the following options: debug_print_backtrace(3) options +----------------------------+---------------------------------------------------+ |DEBUG_BACKTRACE_IGNORE_ARGS | | | | | | | Whether or not to omit the "args" index, and | | | thus all the function/method arguments, to save | | | memory. | | | | +----------------------------+---------------------------------------------------+ o $limit - As of 5.4.0, this parameter can be used to limit the number of stack frames printed. By default ($limit= 0) it prints all stack frames. RETURN VALUES
No value is returned. CHANGELOG
+--------+-----------------------------------------+ |Version | | | | | | | Description | | | | +--------+-----------------------------------------+ | 5.4.0 | | | | | | | Added the optional parameter $limit. | | | | | 5.3.6 | | | | | | | Added the optional parameter $options. | | | | +--------+-----------------------------------------+ EXAMPLES
Example #1 debug_print_backtrace(3) example <?php // include.php file function a() { b(); } function b() { c(); } function c(){ debug_print_backtrace(); } a(); ?> <?php // test.php file // this is the file you should run include 'include.php'; ?> The above example will output something similar to: #0 c() called at [/tmp/include.php:10] #1 b() called at [/tmp/include.php:6] #2 a() called at [/tmp/include.php:17] #3 include(/tmp/include.php) called at [/tmp/test.php:3] SEE ALSO
debug_backtrace(3). PHP Documentation Group DEBUG_PRINT_BACKTRACE(3)
Man Page