#29863 [NEW]: Not constant default argument

From: Date: Fri, 27 Aug 2004 10:31:44 +0000
Subject: #29863 [NEW]: Not constant default argument
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-65343@lists.php.net to get a copy of this message
From: viraptor at sol dot wsiz dot rzeszow dot pl Operating system: Any PHP version: 5.0.1 PHP Bug Type: Feature/Change Request Bug description: Not constant default argument 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; ..... } -- Edit bug report at http://bugs.php.net/?id=29863&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29863&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29863&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29863&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=29863&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29863&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29863&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29863&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29863&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29863&r=support Expected behavior: http://bugs.php.net/fix.php?id=29863&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29863&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29863&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29863&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29863&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29863&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29863&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29863&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29863&r=float

« previous php.bugs (#65343) next »