Merge pull request #1638 from xssc/patch-1

[php/en] Added variable amount of parameters as of php 5.6+
This commit is contained in:
Adam Bard 2015-10-19 14:30:28 +08:00
commit 329166d986

View File

@ -452,6 +452,16 @@ function parameters() {
parameters('Hello', 'World'); // Hello | 0 - Hello | 1 - World | 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 * Includes
*/ */