php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29923 Assignment operations inside class methods not working
Submitted: 2004-08-31 19:24 UTC Modified: 2004-09-01 09:38 UTC
From: bugs dot php dot net at chsc dot dk Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.1 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: bugs dot php dot net at chsc dot dk
New email:
PHP Version: OS:

 

 [2004-08-31 19:24 UTC] bugs dot php dot net at chsc dot dk
Description:
------------
When called from inside a class method, $this->foo += 2 does not increment the variable.

$this->foo = $this->foo + 2 appears to work, though.

This looks related to bug 27798.

Reproduce code:
---------------
<?php

class foo {
    var $bar = 1;

    function baz() {
        $this->bar += 2;
        var_dump($this->bar);
        var_dump(get_object_vars($this));
    }
}

$f = new foo();
$f->baz();

$f->bar += 4;
var_dump($f->bar);

?>

Expected result:
----------------
int(3)
array(1) {
  ["bar"]=>
  int(3)
}
int(7)


Actual result:
--------------
int(1)
array(2) {
  ["bar"]=>
  int(1)
  [0]=>
  int(2)
}
int(5)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-01 08:39 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip
 [2004-09-01 08:39 UTC] derick@php.net
Extra note: this works fine for me.
 [2004-09-01 09:29 UTC] bugs dot php dot net at chsc dot dk
Sorry, it's not a bug in PHP but in the Zend Optimizer. 

Changing zend_optimizer.optimization_level from 15 to 0 in php.ini fixes the problem. We'll report this to Zend.
 [2004-09-01 09:38 UTC] bugs dot php dot net at chsc dot dk
Marking Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 15:01:28 2024 UTC