<?php
class test{
const KEY = 'test';//全大写
public function test(){
$key = self::KEY;
echo $key;
}
}
php定义常量define('key','value');和const key = value;
const可以在类中定义,但是define不可以。
<?php
class test{
const KEY = 'test';//全大写
public function test(){
$key = self::KEY;
echo $key;
}
}
php定义常量define('key','value');和const key = value;
const可以在类中定义,但是define不可以。
转载于:https://my.oschina.net/luqiuren666/blog/913449