I just have found out that there is a function called func_get_arg in PHP which enables developer to use variant style of getting arguments. It seems to be very us
func_get_arg
I usually use func_get_args() which is easier to use if wanting multiple arguments.
func_get_args()
For example, to recreate PHP's max().
max()
function max() { $max = -PHP_INT_MAX; foreach(func_get_args() as $arg) { if ($arg > $max) { $max = $arg; } } return $max; }
CodePad.
Now you can do echo max(1,5,7,3) and get 7.
echo max(1,5,7,3)
7