#24462 [Opn->Bgs]: alternate way to call functions with parameters

From: Date: Wed, 02 Jul 2003 18:02:57 +0000
Subject: #24462 [Opn->Bgs]: alternate way to call functions with parameters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43101@lists.php.net to get a copy of this message
ID: 24462 Updated by: derick@php.net Reported By: waxmop at sarcastic-horse dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: ALL PHP Version: 4.3.2 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the existing bug instead. Thank you for your interest in PHP. Already proposed in some other report. And no, this will not be supported either. Previous Comments: ------------------------------------------------------------------------ [2003-07-02 12:15:00] waxmop at sarcastic-horse dot com 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 this bug report at http://bugs.php.net/?id=24462&edit=1

« previous php.bugs (#43101) next »