php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52727 Combined function default argument value
Submitted: 2010-08-29 05:00 UTC Modified: 2010-08-30 18:26 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: grzegorz129 at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.3 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-29 05:00 UTC] 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 ')'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-29 05:03 UTC] 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-30 18:26 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-08-30 18:26 UTC] johannes@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 18:01:34 2024 UTC