php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12809 function calls, default arguments and passing references
Submitted: 2001-08-17 09:17 UTC Modified: 2012-08-13 21:20 UTC
From: anders at gatefive dot fi Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0.4pl1 OS: linux 2.2
Private report: No CVE-ID: None
 [2001-08-17 09:17 UTC] anders at gatefive dot fi
In a class I often use functions like this to get/set variables:
class example {
  var $somevar;
function Somevar($arg = NULL) {
  if (!is_null($arg))
    $this->somevar = $arg;
return $this->somevar;
}
}

Everything is ok, but sometimes I would like to be able to do the same
with references, like so:
class example2 {
  var $someobject;
function &Someobject(&$arg = NULL) {
  if (!is_null($arg))
    $this->someobject = &$arg;
return $this->someobject;
}
}

The second example will throw an parse error, expecting ) after &$arg.

I suppose this isn't an bug, but rather something not implemented or is intensional.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-17 09:26 UTC] derick@php.net
Default referenced variabeles are not yet supported.
They probably will be in the second release of the Zend engine. Suspending for now.

Derick
 [2012-08-13 21:20 UTC] nikic@php.net
Closing as this is supported by now.
 [2012-08-13 21:20 UTC] nikic@php.net
-Status: Suspended +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 13:01:29 2024 UTC