Skip to content

Instantly share code, notes, and snippets.

@superbrothers
Created January 25, 2011 14:46
Show Gist options
  • Save superbrothers/795002 to your computer and use it in GitHub Desktop.
Save superbrothers/795002 to your computer and use it in GitHub Desktop.
<?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