Last active
June 7, 2017 08:34
-
-
Save kadoyau/2e5c31a98835a2fbfa5ca9e6ebd832cd to your computer and use it in GitHub Desktop.
PHPのConstの中でConstを使う
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 Constant { | |
const MEW = "Mew"; | |
} |
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 | |
require_once __DIR__ . "/Constant.php"; | |
class UseConstant { | |
const USEMEW = [ | |
Constant::MEW, | |
]; | |
public function mew(){ | |
var_dump(self::USEMEW) . PHP_EOL; | |
} | |
} | |
$a = new UseConstant(); | |
$a->mew(); // shows [ "Mew" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment