All pastes #1171273 Raw Edit

rewbs

public php v1 · immutable
#1171273 ·published 2008-08-14 10:29 UTC
rendered paste body
<?phpclass C { public static $p = 'original'; }class D extends C {	}class E extends D {	}echo "\nInherited static properties refer to the same value accross classes:\n";var_dump(C::$p, D::$p, E::$p);echo "\nChanging one changes all the others:\n";D::$p = 'changed.all';var_dump(C::$p, D::$p, E::$p);echo "\nBut because this is implemented using PHP references, the reference set can easily be split:\n";$ref = 'changed.one';D::$p =& $ref;var_dump(C::$p, D::$p, E::$p);?>Output on php 5.2 and 5.3:Inherited static properties refer to the same value accross classes:string(8) "original"string(8) "original"string(8) "original"Changing one changes all the others:string(11) "changed.all"string(11) "changed.all"string(11) "changed.all"But because this is implemented using PHP references, the reference set can easily be split:string(11) "changed.all"string(11) "changed.one"string(11) "changed.all"