summaryrefslogtreecommitdiffhomepage
path: root/php.html.markdown
diff options
context:
space:
mode:
authorSawyer Charles <xssc@users.noreply.github.com>2015-10-18 17:46:23 -0500
committerSawyer Charles <xssc@users.noreply.github.com>2015-10-18 17:46:23 -0500
commited4ac31d97b36866a48faf3b9328c320ba55074f (patch)
tree7f851774a1446caaa95d5067bab88b829c86f14c /php.html.markdown
parentba5f3ebc112b52797a9a21fdbba1846885feac2c (diff)
Added variable amount of parameters as of php 5.6+
Diffstat (limited to 'php.html.markdown')
-rw-r--r--php.html.markdown10
1 files changed, 10 insertions, 0 deletions
diff --git a/php.html.markdown b/php.html.markdown
index 5bc2ddce..e7b57b4b 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -445,6 +445,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
*/