Skip to content

Instantly share code, notes, and snippets.

@e0ipso
Created February 20, 2015 15:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e0ipso/c0e314325c3c1653c87b to your computer and use it in GitHub Desktop.
Save e0ipso/c0e314325c3c1653c87b to your computer and use it in GitHub Desktop.
About constant overrides and Late Static Binding
<?php
class A {
const C = 'Class A';
public static function constantSelf() {
print self::C . PHP_EOL;
}
public static function constantStatic() {
print static::C . PHP_EOL;
}
}
class B extends A {
const C = 'Class B';
}
print A::constantSelf();
print B::constantSelf();
print A::constantStatic();
print B::constantStatic();
>$ php constants.php
Class A
Class A
Class A
Class B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment