note 32616 deleted from functions.arguments by nikic
| From: | nikic@php.net | Date: | Wed, 30 Apr 2014 15:39:32 +0000 |
| Subject: | note 32616 deleted from functions.arguments by nikic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-199388@lists.php.net to get a copy of this message | ||
Note Submitter: bishop
----
A tiny clarification on the notes of "keeper at odi dot com dot br", et. al.
Functions explicitly prototyped with formal parameters passed by reference can't have default
values. However, functions prototyped to assign default values to formal parameters may be passed
references.
For example, this is a parse error:
function foo(&$bar = null) {
// formal parameters as references can't have default values
$bar = 242;
}
While this is perfectly legal (and probably what you want, mostly):
function foo($bar = null) {
$bar = 242;
}
foo(); // valid call, no warnings about missing args
foo(&$x); // valid call, post $x == 242