फंक्शन के आर्गुमेंट को इस तरह निर्दिष्ट किया जा सकता है कि वह किसी भी संख्या में आर्गुमेंट ले सके:
<?php
function actOnItems(...$items) {
// $items is an array containing 0 or more values
// used to call the function.
}
actOnItems(1, 2, 3, 4); // $items => [1, 2, 3, 4]
यदि अन्य आर्गुमेंट के साथ वेरिएबल लंबाई वाला आर्गुमेंट निर्दिष्ट किया जाए, तो वह अंतिम आर्गुमेंट होना चाहिए।
<?php
function writeLines($file_handle, ...$lines)
{
put_file_contents($file_handle, implode("\n", $lines));
}
writeLines('file.txt', "a", "b", "c");