I am really confused with this one. Here’s my code
class inner
{
var $val = 0;
}
class outer
{
var $obj=null;
function outer()
{
$this->obj = new inner;
}
function get_obj()
{
return $this->obj;
}
}
$app = new outer;
$obj = &$app->get_obj(); //get object by reference (& is not necessary in PHP5)
$obj->val = 1; //change something
echo $app->obj->val; //check whether it affected the original object source
//here it should display 1
When I am testing this on my local server, which is PHP 5.2.10-2ubuntu6.4, everything works fine and it displays 1. When I am testing this on my customer’s PHP Version 5.2.9 server, it displays 0. Is there some known PHP bug or may be some php.ini setting that could affect this behavior?
If not works, try replace this
By this
Usefull links:
http://php.net/manual/en/language.references.pass.php
http://php.net/manual/en/language.oop5.references.php