php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #520 reference variables in class functions
Submitted: 1998-07-08 11:33 UTC Modified: 1998-07-10 09:07 UTC
From: be at shonline dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0 Final Release OS: solaris 2.5.1
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: be at shonline dot de
New email:
PHP Version: OS:

 

 [1998-07-08 11:33 UTC] be at shonline dot de
defining a function with reference variables

like this:

function funcname(&$parm) {
;
}

doesnt work inside classes. The following script documents this
(sorry i could not get it shorter)

<?php
class a {
 
  function one(&$s) {
  # see -------^
 
    $s="bar";
  }
 
  function two() {
 
    $s="foo";
    $this->one($s);
    # see -----^
    print $s."\n";
 
    $s="foo";
    $this->one(&$s);
    # see -----^
    print $s."\n";
 
  }
 
}
 
$o = new a;
$o->two();
 
?>

It should produce:

bar
bar

But it produces

foo
bar

I suspect this behaviour to cause a core dump under certain circumstances.

I assume this is a bug?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-07-10 09:07 UTC] zeev
Definitely is a bug.  *THANKS* for reporting it with such a reproduceable script.  I've been able to easily reproduce the problem
and track it down.  It's fixed in the latest CVS, and will be a part of PHP 3.0.2.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC