From: waxmop at sarcastic-horse dot com
Operating system: ALL
PHP version: 4.3.2
PHP Bug Type: Feature/Change Request
Bug description: alternate way to call functions with parameters
Description:
------------
<pre>
If I have a function like this:
<?php
function foo($v1='aaa', $v2='bbb', $v3='ccc', $v4='ddd')
{
?>
<p>v1 is <?=$v1?></p>
<p>v2 is <?=$v2?></p>
<p>v3 is <?=$v3?></p>
<p>v4 is <?=$v4?></p>
<?php
}
?>
If I want to override the values for $v2, and $v4, I've gotta list all the
parameters after v1.
In python, if I had the same function:
def foo(v1='aaa', v2='bbb', v3='ccc', v4='ddd'):
print "v1 is ", v1
print "v2 is ", v2
print "v3 is ", v3
print "v4 is ", v4
#end foo definition
And I wanted to override the vars, I could call the function like this:
foo(v2='xxx', v3='zzz');
But this isn't possible in PHP. The python way allows for more obvious
self-documenting code. Is there any chance this could get added?
</pre>
--
Edit bug report at http://bugs.php.net/?id=24462&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=24462&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=24462&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24462&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24462&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24462&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24462&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24462&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24462&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24462&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24462&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24462&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24462&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24462&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24462&r=gnused