func_get_arg() and func_get_args() functions in PHP

By: Marlin  

You may pass any number of extra parameters to a function, regardless of the prototyping. In addition, the arguments passed to a function will be available via the variable names defined in the function prototype, as well as via the func_get_arg() and func_get_args() functions.
For example:
function printme ($arg) {
    for ($ndx = 0; $ndx < $num_args; ++$ndx)
        $output .= func_get_arg ($ndx);
    print $output;
}
printme ("one ", "two"); # This prints "one two".

This behavior is useful for setting default values for function arguments and for ensuring that a certain number of arguments get passed to a function.





Most Viewed Articles (in PHP )

Anonymous functions as properties in Classes in PHP

use() in PHP

All possible substrings in a String in PHP

PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/php4/lib/php/extensions/no-debug ......

Decrypting files using GnuPG (GPG) via PHP

Integers and Floating-Point Numbers in PHP

XMLRPC for PHP - A simple client and server program

Using class within a function in PHP

A Tutorial on Timezones and Timestamps

error: "Service Unavailable" after installing PHP to a Windows XP x64 Pro

PHP 5.1.4 INSTALLATION on Solaris 9 (Sparc)

Building PHP 5.x with Apache2 on SuSE Professional 9.1/9.2

Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring PHP 5.x with Oracle 9i

Cannot load /usr/local/apache/libexec/libphp4.so into server: ld.so.1:......

Function to sort array by elements and count of element in PHP

Latest Articles (in PHP)

Comment on this tutorial