summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2015-10-19 14:30:28 +0800
committerAdam Bard <github@adambard.com>2015-10-19 14:30:28 +0800
commit329166d986c905699c17a2ef797ab7995fee9624 (patch)
treec729afe635e0623d481cfc68d1ff2524ab3707fc
parent7c6db1787481b5e72058540492df44eb0a6bd955 (diff)
parentb4c8ff365ee1d633470ced72de5f540744fa921a (diff)
Merge pull request #1638 from xssc/patch-1
[php/en] Added variable amount of parameters as of php 5.6+
-rw-r--r--php.html.markdown10
1 files changed, 10 insertions, 0 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 127e601b..cf9544b3 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -452,6 +452,16 @@ function parameters() {
parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World |
+// Since PHP 5.6 you can get a variable number of arguments
+function variable($word, ...$list) {
+ echo $word . " || ";
+ foreach ($list as $item) {
+ echo $item . ' | ';
+ }
+}
+
+variable("Separate", "Hello", "World") // Separate || Hello | World |
+
/********************************
* Includes
*/