#41142 [NEW]: Default parameters for functions

From: Date: Fri, 20 Apr 2007 00:32:04 +0000
Subject: #41142 [NEW]: Default parameters for functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111710@lists.php.net to get a copy of this message
From: flopin at webgarden dot cz Operating system: any PHP version: 6CVS-2007-04-20 (snap) PHP Bug Type: Feature/Change Request Bug description: Default parameters for functions Description: ------------ It would be nice to find a way how to explicitly set a name of parameter passed to the function, which has default values for its parameters, so i could change only the values i need to change. It can be bypassed in several ways (arrays, classes etc.), but it allways results in bunches of code, which is not nessesary and makes the program less practical. Bug #17076 suggests a possibility of omitting default parameters, but the solution still requires to keep order of parameters. Reproduce code: --------------- function x($a='AAA', $b='BBB') { print $a; print $b; } x($b='111'); //or any other suitable syntax Expected result: ---------------- AAA111 Actual result: -------------- 111BBB -- Edit bug report at http://bugs.php.net/?id=41142&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41142&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41142&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41142&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41142&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41142&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41142&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41142&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41142&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41142&r=support Expected behavior: http://bugs.php.net/fix.php?id=41142&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41142&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41142&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41142&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41142&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41142&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41142&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41142&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41142&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41142&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41142&r=mysqlcfg

« previous php.bugs (#111710) next »