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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC