php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4281 cannot use a referenced argument with defaulting
Submitted: 2000-04-30 03:36 UTC Modified: 2000-07-04 16:05 UTC
From: andy at qabobala dot xapnet dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 4 OS: Linux 2.2.14
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: andy at qabobala dot xapnet dot com
New email:
PHP Version: OS:

 

 [2000-04-30 03:36 UTC] andy at qabobala dot xapnet dot com
You cant use a reference with a default value (an optional function arg) when defining a function-- the parser will choke on this.

function ($somearg, &$object_ref = 0) {
  if($object_ref == 0) {
     ...
   }
  else { ... }
}

Maybe this fails because php needs a predefined NULL - which is a reference to the NULL object.  


later...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-04 16:05 UTC] stas at cvs dot php dot net
Yes you cannot use defaults for reference. 
I am not sure this is possible at all in PHP. 
Initializer should eb a constant, while reference parameter should be modifiable.
 [2003-05-21 05:24 UTC] sailormax at inbox dot lv
I need take argument-reference, but not obligatory. I write:
---------------------
function foo($arg = '')
{
 ...
}
foo(&$zz); // or foo()
---------------------
and have warning: Call-time pass-by-reference has been deprecated...

in documentation wrote:
~~~~~~~~~~~~~~~~~~~~~~~
Whether to enable the ability to force arguments to be passed by reference at function call time. This method is deprecated and is likely to be unsupported in future versions of PHP/Zend.
~~~~~~~~~~~~~~~~~~~~~~

And how I can now realize not obligatory argument-reference?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 17:01:27 2024 UTC