Created
April 23, 2013 09:29
-
-
Save simonewebdesign/5442146 to your computer and use it in GitHub Desktop.
Optional parameters in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foo() { | |
$numargs = func_num_args(); | |
echo "Number of arguments: $numargs<br />\n"; | |
if ($numargs >= 2) { | |
echo "Second argument is: " . func_get_arg(1) . "<br />\n"; | |
} | |
$arg_list = func_get_args(); | |
for ($i = 0; $i < $numargs; $i++) { | |
echo "Argument $i is: " . $arg_list[$i] . "<br />\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment