Last active
September 5, 2022 07:30
-
-
Save shtrom/b98252b215346c625a449010c10a2b4f to your computer and use it in GitHub Desktop.
`static` vs `self`
This file contains 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 VarHolder { | |
const VAR = 2; | |
public function showVar() { | |
echo self::VAR; | |
echo static::VAR; | |
} | |
} |
This file contains 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 ChildVarHolder extends VarHolder { | |
const VAR = 4; | |
public function doSomething() { | |
echo self::VAR; | |
echo static::VAR; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment