php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34372 varibles of A class why not change?
Submitted: 2005-09-05 06:15 UTC Modified: 2005-09-05 08:52 UTC
From: hightman2 at yahoo dot com dot cn Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 4.4.0 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-09-05 06:15 UTC] hightman2 at yahoo dot com dot cn
Description:
------------
the object's method was called as 'call back' function

Reproduce code:
---------------
<?php
class hello {
  var $me;
  function hello() {
    $this->me = 1;
    register_shutdown_function(array(&$this, 'show'));
  }
  function show() {
    echo $this->me . "\n";
  }
  function add() {
    $this->me++;
  } 
}
$h = new hello;
$h->add();
echo "real value: ";
$h->show();
echo "cb value: ";
?>

Expected result:
----------------
real value: 2
cb value: 2

Actual result:
--------------
real value: 2
cb value: 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-05 08:52 UTC] sniper@php.net
That's what you get with playing around with references and objects in PHP 4. Fixed in PHP 5.1 and above. Wont fix elsewhere.

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC