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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zartashzulfiqar at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Sep 16 20:00:01 2025 UTC