Edit report at http://bugs.php.net/bug.php?id=52727&edit=1
ID: 52727
User updated by: grzegorz129 at gmail dot com
Reported by: grzegorz129 at gmail dot com
Summary: Combined function default argument value
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: All
PHP Version: 5.3.3
Block user comment: N
New Comment:
p.s. "Wynik" mean "result" in polish - I do copy&paste of code from post
on polish
form (I first asked more experienced codders than me before submitting
bug
reaport)
Previous Comments:
------------------------------------------------------------------------
[2010-08-29 05:00:34] grzegorz129 at gmail dot com
Description:
------------
First of all - I marked it as feature/chamge request (not bug) bcs it`s
not so
important but maybe it`s a bug.
Official manual quote:
"The default value must be a constant expression, not (for example) a
variable, a
class member or a function call."
Code written below is correct according to the documentation but
interpreter
generate parse error: syntax error, unexpected '.', expecting ')'
function foobar($a = "abc"."def") { print($a); } //Wynik: Parse error:
syntax
error, unexpected '.', expecting ')'
Test script:
---------------
define("TEST", "abc");
function foo($a = TEST) { print($a); } //Res: abc
function bar($a = "def") { print($a); } //Res: def
function foobar($a = TEST."def") { print($a); } //Wynik: Parse error:
syntax error, unexpected '.', expecting ')'
//abstract but also causes parse error
function foobar($a = "abc"."def") { print($a); } //Wynik: Parse error:
syntax error, unexpected '.', expecting ')'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52727&edit=1