Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created July 26, 2021 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricMcWinNer/5dcb3ff6c152069feec76aaf5835cf13 to your computer and use it in GitHub Desktop.
Save EricMcWinNer/5dcb3ff6c152069feec76aaf5835cf13 to your computer and use it in GitHub Desktop.
<?php
class A {
public static function iAm() {
return "A";
}
}
// echo A::iAm(); // "A"
class B extends A {
public static function iAm() {
echo "I am B. I come from " . parent::iAm();
}
}
B::iAm(); // "I am B. I come from A"
class C extends B {
public static function iAm() {
echo "I am C. I come from " . parent::class . "\n";
}
public static function iComeFrom() {
parent::iAm();
}
}
echo C::iAm(); // "I am C. I come from B"
echo C::iComeFrom(); // "I am B. I come from A"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment