Req #52727 [Opn->Bgs]: Combined function default argument value
| From: | johannes@php.net | Date: | Mon, 30 Aug 2010 16:26:44 +0000 |
| Subject: | Req #52727 [Opn->Bgs]: Combined function default argument value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-153937@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
Updated by: johannes@php.net
Reported by: grzegorz129 at gmail dot com
Summary: Combined function default argument value
-Status: Open
+Status: Bogus
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: All
PHP Version: 5.3.3
Block user comment: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"abc"."def" is an expression. There is no good way to allow a useful
"subset" for these places (There are more like class constant
declaration etc.) so we can't fix this without major language changes.
Previous Comments:
------------------------------------------------------------------------
[2010-08-29 05:03:16] grzegorz129 at gmail dot com
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)
------------------------------------------------------------------------
[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