php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #19252 function only accepts scalars or constants as default values
Submitted: 2002-09-05 11:09 UTC Modified: 2003-06-19 06:21 UTC
From: jc at mega-bucks dot co dot jp Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0 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: jc at mega-bucks dot co dot jp
New email:
PHP Version: OS:

 

 [2002-09-05 11:09 UTC] jc at mega-bucks dot co dot jp
Could you add to the docs in the section on functions and default argument values that default values can only be scalers or constants?

these won't work:

1- function a ($b = $val) {}

2- function b ($a = another_function()) {}

This link offers some workarounds, eventhough it would be really nice to be able to do #2, don't you think ;)

http://marc.theaimsgroup.com/?l=php-general&m=91877248424055&

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-05 15:22 UTC] kalowsky@php.net
No it wouldn't be nice to do #2, thats just not fun programming practice/maintaince.  

Can you give a URL to the section of the documentation you're asking to be updated?
 [2002-09-26 19:56 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-01-31 13:04 UTC] philip@php.net
Yeah, we may as well mention this here:

file:    phpdoc/{lang}/language/functions.xml 
section: <sect2 id="functions.arguments.default">
 [2003-06-17 04:27 UTC] betz@php.net
It seems this is documented at:
http://www.php.net/manual/en/functions.arguments.php#functions.arguments.default

Maybe a bit hidden
 [2003-06-17 04:35 UTC] jc at mega-bucks dot co dot jp
I agree that is *is* documented, even if a bit hidden. I am happy if the documentation is left as is or changed to this:

"The default value must be a constant expression, not (for example) a variable, class member, <NEW ADDITION> or function call </NEW ADDITION>.

Thanks.
 [2003-06-19 06:06 UTC] betz@php.net
Just incorporated your suggestion into the manual. 
Next time the manual is build, the changes will show up on the 
website. 
 
Thanks for your report 
 [2003-06-19 06:21 UTC] jc at mega-bucks dot co dot jp
Thanks! Keep up the good work. God knows *I* hate documentting my code so I highly appreciate the work that goes in to PHP's documentation!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 16:01:27 2024 UTC