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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 32 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC