php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29863 Not constant default argument
Submitted: 2004-08-27 12:31 UTC Modified: 2004-08-27 13:16 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: viraptor at sol dot wsiz dot rzeszow dot pl Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.1 OS: Any
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: viraptor at sol dot wsiz dot rzeszow dot pl
New email:
PHP Version: OS:

 

 [2004-08-27 12:31 UTC] viraptor at sol dot wsiz dot rzeszow dot pl
Description:
------------
When started using php 5 I tried to do something like this:
class A {
  private $var;
  function B($arg = $this->var) { ... }
}
Got 'unexpected T_VARIABLE' or course, but I think it would be a nice option to add in a future releases - default arguments computed when function is called. It could be especially useful when used inside classes.
Probably the same as bug #6566, but if it disappeared after php3, it certainly should be turned on again in php5

Expected result:
----------------
Compute default arguments when calling a function, that can create those itself. It will help if you need something like:
function A ($arg = NULL) {
   if($arg == NULL) $arg=$another_arg;
   .....
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-27 13:16 UTC] derick@php.net
You can only use constants as defaults for parameters to functions, this is not going to be changed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 29 07:01:31 2024 UTC