ini_set('zend.ze1_compatibility_mode',0);
Just needed to turn that off. This thing has caused me tons of problems in the past with SPL classes. I think I'll just always keep it turned off from now on.
zend.ze1_compatibility_mode boolean
Enable compatibility mode with Zend Engine 1 (PHP 4). It affects the cloning, casting (objects with no properties cast to FALSE or 0), and comparing of objects. In this mode, objects are passed by value instead of reference by default.
Updated with simplified code.
Shouldn't the last line echo 'banana'?
Code: Select all
<?
class object
{ var $testvar = ''; }
$A = new object;
$A->testvar = 'apple';
echo '<p>A = '.$A->testvar.'</p>';
$B = $A;
echo '<p>B = '.$B->testvar.'</p>';
$B->testvar = ' BANANA - changed testvar value with B';
echo '<p>A after changing B = '.$A->testvar.'</p>';
?> Code: Select all
A = apple
B = apple
A after changing B = appleCode: Select all
A = apple
B = apple
A after changing B = BANANA - changed testvar value with B