Created
January 25, 2011 14:46
-
-
Save superbrothers/795002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
protected static $_a = 'a'; | |
public static function get() { | |
return self::$_a; | |
} | |
} | |
var_dump(A::get()); // a | |
class B extends A{ | |
public static function set($str) { | |
self::$_a = $str; | |
} | |
} | |
B::set('b'); | |
var_dump(B::get()); // b | |
var_dump(A::get()); // b | |
class C { | |
private static $_c = 'c'; | |
protected static function set($str) { | |
self::$_c = $str; | |
} | |
public static function get() { | |
return self::$_c; | |
} | |
} | |
var_dump(C::get()); // c | |
class D extends C { | |
public static function set($str) { | |
parent::set($str); | |
} | |
} | |
D::set('d'); | |
var_dump(D::get()); // d | |
var_dump(C::get()); // d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment