有时候自己定义了一堆常量,比如枚举值的时候
class Model_Info extends Model_Base
{
const $USER =1;
const $DRIVER =2;
const $ENTERPRISE =3;
//调用
Model_Info::DRIVER => 'XB_SJ',
Model_Info::USER => 'BD_YH',
Model_Info::ENTERPRISE => 'BJ_QY',
//静态常量调用配置中心
$bustr = ("ACCOUNT_CENTER_".$bustr);
$config = __getEnvConfig(App_Config::$$bustr);//静态常量调用
$this->cId = $config['channel_id'];
$this->appId = $config['app_id'];
}
突然发现常量比较优雅的调用配置
class App_Config
{
//司机配置
static $ACCOUNT_CENTER_SJ = [
'dev' => [
'app_id' => '1204600479',
'c_id' => '190112',
],
'stg' => [
'app_id' => '1204600479',
'c_id' => '190112',
],
];
//用户配置
static $ACCOUNT_CENTER_YH = [
'dev' => [
'app_id' => '1204600479312313',
'c_id' => '190114',
],
'stg' => [
'app_id' => '1204600479312313',
'c_id' => '190114',
],
];
//企业配置
static $ACCOUNT_CENTER_QY = [
'dev' => [
'app_id' => '1204600473145134121239',
'c_id' => '190113',
],
'stg' => [
'app_id' => '1204600473145134121239',
'c_id' => '190113',
],
];
}
|