summaryrefslogtreecommitdiffhomepage
path: root/php.html.markdown
diff options
context:
space:
mode:
authorAkshay Kalose <AkshayProductions@gmail.com>2015-10-16 20:36:19 -0400
committerAkshay Kalose <AkshayProductions@gmail.com>2015-10-16 20:36:19 -0400
commitc2b68d138cb881994836040fb10e220f0d4fcc93 (patch)
treee4be77dff89cbc263c3b3c9aae1e6ed470abbb35 /php.html.markdown
parent9bb82465e6ad4b602f4fb0a8ff3877dddc4ca3e5 (diff)
Add Getting Parameters From Functions in PHP
Diffstat (limited to 'php.html.markdown')
-rw-r--r--php.html.markdown15
1 files changed, 15 insertions, 0 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 39ec5aef..9d9c5847 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -426,6 +426,21 @@ echo $function_name(1, 2); // => 3
// Useful for programatically determining which function to run.
// Or, use call_user_func(callable $callback [, $parameter [, ... ]]);
+
+// You can get the all the parameters passed to a function
+function parameters() {
+ $numargs = func_num_args();
+ if ($numargs > 0) {
+ echo func_get_arg(0) . ' | ';
+ }
+ $args_array = func_get_args();
+ foreach ($args_array as $key => $arg) {
+ echo $key . ' - ' . $arg . ' | ';
+ }
+}
+
+parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World |
+
/********************************
* Includes
*/