php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14306 Need a something to pass to use default function values
Submitted: 2001-11-30 17:49 UTC Modified: 2010-12-31 22:57 UTC
From: mikep at oeone dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.1.0 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mikep at oeone dot com
New email:
PHP Version: OS:

 

 [2001-11-30 17:49 UTC] mikep at oeone dot com
I would like a way to pass something into a function and have it use the default values.

For eg., if I have the function
function test( $value, $value1=1, $value2=2 )

and I call it like test( "value", "", "2" ) I think it should use 1 for $value1.  It currently does not, but I'd like to be able to pass something in to make it use the default value, like:
test( "value", NULL, "2" )
I know you can rewrite the function to test for $value1="", but I'd rather not do that.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-01 23:18 UTC] zak@php.net
This issue has been raised on this list and on the Zend 
Engine mailing list. IIRC it has always been shot down.

Perhaps review the list archives to see what has been 
discussed in the past, consider the arguments and - if you 
still desire the feature - present your case again.

Personally, if I wanted the feature, I would think that a 
syntax like:

my_function ('arg 1', ,'arg 3);

would look/work best...

Good luck!

 [2010-12-31 22:57 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-31 22:57 UTC] jani@php.net
Shot down again. Provide proper RFC at http://wiki.php.net/rfc/ if you wish to get this. In the meantime, use arrays instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 01 19:01:30 2024 UTC