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: 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: hightman2 at yahoo dot com dot cn
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 05:01:28 2025 UTC