php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73550 PHP Function Call Proposal
Submitted: 2016-11-16 22:32 UTC Modified: 2016-11-17 05:58 UTC
From: zartashzulfiqar at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 7.1.0RC6 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
22 + 33 = ?
Subscribe to this entry?

 
 [2016-11-16 22:32 UTC] zartashzulfiqar at gmail dot com
Description:
------------
function myFunction($var1, $var2=3, $var3=4, $var4=5) {
echo $var1."\n".$var2."\n".$var3."\n".$var4;
}

Test script:
---------------
myFunction('Test Call', 3, 4, 10);

Expected result:
----------------
I expect this Output:

Test Call
3
4
10

Actual result:
--------------
Actual Same:
Test Call
3
4
10

But Issue is:
Now see that I only want to change $var4 value in my function. All other default values will remain same. But I have to remember every value and pass it through the function.

I am proposing a this change like this:

myFunction('Default Value', $var4=10);

so that Every developer can only pass value with specific variable name. This issue arises at many function when we used in our development. I think this change will be a big feature for developer.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-17 05:58 UTC] requinix@php.net
-Status: Open +Status: Suspended
 [2016-11-17 05:58 UTC] requinix@php.net
See the Named Parameters RFC (currently inactive)
 [2016-11-17 05:58 UTC] requinix@php.net
Forgot the link. https://wiki.php.net/rfc/named_params
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 14:01:31 2024 UTC