Created
February 16, 2017 14:31
-
-
Save tanakahisateru/5c1832f60646cd56c5bdbf50265f3374 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 BaseObject | |
| { | |
| public function differentStaticMethodCallingStyle() | |
| { | |
| return [ | |
| 'self::' => self::staticMethod(), | |
| 'static::' => static::staticMethod(), | |
| '$this->' => $this->staticMethod(), | |
| ]; | |
| } | |
| protected static function staticMethod() | |
| { | |
| return "base object called"; | |
| } | |
| } | |
| class ExtendedObject extends BaseObject | |
| { | |
| protected static function staticMethod() | |
| { | |
| return "extended object called"; | |
| } | |
| } | |
| print_r((new ExtendedObject())->differentStaticMethodCallingStyle()); | |
| // Array | |
| // ( | |
| // [self::] => base object called | |
| // [static::] => extended object called | |
| // [$this->] => extended object called | |
| // ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment