In CodeIgniter, where should I declare my global variables?

三世轮回 提交于 2019-12-06 17:06:02

问题


I want to declare some global variables and global constants. Normally, I would put them in the includes/global.php of my own custom framework.

Where should I define globals in CodeIgniter? Here's an example of the globals I want to declare:

define('USERSTAT_OFFLINE', 0);
define('USERSTAT_ONLINE', 1);
define('USERSTAT_AWAY', 2);
define('USERSTAT_BUSY', 3);

$PAYMENT_PLANS = array();
$PAYMENT_PLANS[] = array('id'=>1, 'name'=>'Trial');
$PAYMENT_PLANS[] = array('id'=>2, 'name'=>'Premium Plan');

回答1:


You may utilise config file (system/application/config/config.php) to set configuration related variables.

Or use constant file (system/application/config/constants.php) to store site preference constants.



来源:https://stackoverflow.com/questions/1671813/in-codeigniter-where-should-i-declare-my-global-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!