在CodeIgniter中,应该在哪里声明我的全局变量? [英] In CodeIgniter, where should I declare my global variables?

查看:63
本文介绍了在CodeIgniter中,应该在哪里声明我的全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想声明一些全局变量和全局常量。通常,我会将它们放在我自己的自定义框架的include / global.php中。

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.

我应该在CodeIgniter的哪里定义全局变量?以下是我要声明的全局变量的示例:

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');


推荐答案

您可以使用配置文件(系统/ application / config / config.php )来设置与配置相关的变量。

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

或使用常量文件( system / application / config / constants.php )存储网站偏好设置常量。

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

这篇关于在CodeIgniter中,应该在哪里声明我的全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆