|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-02 13:02 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 16:00:02 2025 UTC |
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>