note 114065 added to functions.arguments
| From: | HorstSchirmeier | Date: | Wed, 08 Jan 2014 11:58:53 +0000 |
| Subject: | note 114065 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198148@lists.php.net to get a copy of this message | ||
"The default value must be a constant expression" is misleading (or even wrong). PHP
5.4.4 fails to parse this function definition:
function htmlspecialchars_latin1($s, $flags = ENT_COMPAT | ENT_HTML401) {}
This yields a " PHP Parse error: syntax error, unexpected '|', expecting
')' " although ENT_COMPAT|ENT_HTML401 is certainly what a compiler-affine person
would call a "constant expression".
The obvious workaround is to use a single special value ($flags = NULL) as the default, and to set
it to the desired value in the function's body (if ($flags === NULL) { $flags = ENT_COMPAT |
ENT_HTML401; }).
----
Server IP: 212.124.37.9
Probable Submitter: 129.217.43.100
----
Manual Page -- http://php.net/manual/en/functions.arguments.php
Edit -- https://master.php.net/note/edit/114065
Del: integrated -- https://master.php.net/note/delete/114065/integrated
Del: useless -- https://master.php.net/note/delete/114065/useless
Del: bad code -- https://master.php.net/note/delete/114065/bad+code
Del: spam -- https://master.php.net/note/delete/114065/spam
Del: non-english -- https://master.php.net/note/delete/114065/non-english
Del: in docs -- https://master.php.net/note/delete/114065/in+docs
Del: other reasons-- https://master.php.net/note/delete/114065
Reject -- https://master.php.net/note/reject/114065
Search -- https://master.php.net/manage/user-notes.php