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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 09:01:33 2025 UTC