File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes / static_properties_004.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Oct 14 08:02:46 2013 UTC (10 years, 11 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, HEAD
v 5.4.20

    1: --TEST--
    2: Inherited static properties can be separated from their reference set. 
    3: --FILE--
    4: <?php
    5: class C { public static $p = 'original'; }
    6: class D extends C {	}
    7: class E extends D {	}
    8: 
    9: echo "\nInherited static properties refer to the same value across classes:\n";
   10: var_dump(C::$p, D::$p, E::$p);
   11: 
   12: echo "\nChanging one changes all the others:\n";
   13: D::$p = 'changed.all';
   14: var_dump(C::$p, D::$p, E::$p);
   15: 
   16: echo "\nBut because this is implemented using PHP references, the reference set can easily be split:\n";
   17: $ref = 'changed.one';
   18: D::$p =& $ref;
   19: var_dump(C::$p, D::$p, E::$p);
   20: ?>
   21: ==Done==
   22: --EXPECTF--
   23: Inherited static properties refer to the same value across classes:
   24: %unicode|string%(8) "original"
   25: %unicode|string%(8) "original"
   26: %unicode|string%(8) "original"
   27: 
   28: Changing one changes all the others:
   29: %unicode|string%(11) "changed.all"
   30: %unicode|string%(11) "changed.all"
   31: %unicode|string%(11) "changed.all"
   32: 
   33: But because this is implemented using PHP references, the reference set can easily be split:
   34: %unicode|string%(11) "changed.all"
   35: %unicode|string%(11) "changed.one"
   36: %unicode|string%(11) "changed.all"
   37: ==Done==

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>