Created
March 30, 2018 06:54
-
-
Save wiyoe/645a545278b7d48b6934b07fc964bf7c to your computer and use it in GitHub Desktop.
PHP constants
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
| class A | |
| { | |
| const foo = 'bar'; | |
| public function getConstant( $const ) | |
| { | |
| return constant('self::' . $const); | |
| } | |
| } | |
| $classA = new A(); | |
| // Returns bar | |
| echo $classA->getConstant( 'foo' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment