php-4.0.3pl1 and methods

From: Date: Thu, 09 Nov 2000 11:44:29 +0000
Subject: php-4.0.3pl1 and methods
Groups: php.dev 
Request: Send a blank email to php-dev+get-37521@lists.php.net to get a copy of this message
Hi all, There seems to be a problem 4.0.3pl1 regarding invoking methods. Here is a simple script which works correctly with 4.0.2 but outputs strange results with 4.0.3pl1. <?php class a { var $val; function a($val) { $this->val = $val; } function get_val() { return $this->val; } } class b { var $obj; function b($val) { $this->obj = new a($val); } } $o = new b(10); echo serialize($o)."<br>\n"; echo "get val:".$o->obj->get_val()."<br>\n"; echo serialize($o)."<br>\n"; ?> output with php 4.0.2 is O:1:"b":1:{s:3:"obj";O:1:"a":1:{s:3:"val";i:10;}} get val:10 O:1:"b":1:{s:3:"obj";O:1:"a":1:{s:3:"val";i:10;}} but php 4.0.3pl1 seems to corrupt object data: O:1:"b":1:{s:3:"obj";O:1:"a":1:{s:3:"val";i:10;}} get val:10 O:1:"b":1:{} It looks like the problem is somehow related to direct call $o->obj->get_val() - if the method is called like this $aux = $o->obj; $aux->get_val() then the output is as expected. Regards, Dori Seliskar

« previous php.dev (#37521) next »