note 118795 added to functions.arguments

From: Date: Sun, 07 Feb 2016 13:06:37 +0000
Subject: note 118795 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-204892@lists.php.net to get a copy of this message
I wondered if variable length argument lists and references works together, and what the syntax might be. It is not mentioned explicitly yet in the php manual as far as I can find. But other sources mention the following syntax "&...$variable" that works in php 5.6.16. <?php function foo(&...$args) { $i = 0; foreach ($args as &$arg) { $arg = ++$i; } } foo($a, $b, $c); echo 'a = ', $a, ', b = ', $b, ', c = ', $c; ?> Gives a = 1, b = 2, c = 3 ---- Server IP: 72.52.91.14 Probable Submitter: 109.228.152.27 ---- Manual Page -- http://php.net/manual/en/functions.arguments.php Edit -- https://master.php.net/note/edit/118795 Del: integrated -- https://master.php.net/note/delete/118795/integrated Del: useless -- https://master.php.net/note/delete/118795/useless Del: bad code -- https://master.php.net/note/delete/118795/bad+code Del: spam -- https://master.php.net/note/delete/118795/spam Del: non-english -- https://master.php.net/note/delete/118795/non-english Del: in docs -- https://master.php.net/note/delete/118795/in+docs Del: other reasons-- https://master.php.net/note/delete/118795 Reject -- https://master.php.net/note/reject/118795 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204892) next »