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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC