php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #24462 alternate way to call functions with parameters
Submitted: 2003-07-02 12:15 UTC Modified: 2003-07-02 13:02 UTC
From: waxmop at sarcastic-horse dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.2 OS: ALL
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: waxmop at sarcastic-horse dot com
New email:
PHP Version: OS:

 

 [2003-07-02 12:15 UTC] 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>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-02 13:02 UTC] derick@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 04:01:31 2024 UTC