Re: [RFC] skipping optional parameters
| From: | Lester Caine | Date: | Wed, 18 Apr 2012 10:57:34 +0000 |
| Subject: | Re: [RFC] skipping optional parameters | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60182@lists.php.net to get a copy of this message | ||
Daniel Macedo wrote:
function fn1($a = false, $b = nul, $c = 1) { var_dump($a, $b. $c); } // your idea fn1(NULL, NULL, 10), // NULL, NULL, 10 // vs. using a reserved word fn1(default, default, 10), // FALSE, NULL, 10Of cause one little problem here is if the default gets changed in the 'library' then every use of 'default' would need to be checked. Of cause the same problem applies with changing defaults that are used by leaving out the latter parameters on the list, but this just adds another area that needs cross checking. Always including the parameters needed is the safe way in many cases anyway! So leaving them off can be bad practice anyway? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php