Req #52727 [Opn]: Combined function default argument value

From: Date: Sun, 29 Aug 2010 03:03:16 +0000
Subject: Req #52727 [Opn]: Combined function default argument value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153890@lists.php.net to get a copy of this message
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

« previous php.bugs (#153890) next »