在Code Igniter中,我应该在哪里声明我的全局变量?

时间:2022-09-20 10:39:13

I'm new to code igniter.

我是新来的代码点火器。

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.

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

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

我应该在Code Igniter中定义全局变量?这是我想要声明的全局变量的示例:

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 个解决方案

#1


23  

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

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

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

或者使用常量文件(system / application / config / constants.php)来存储站点首选项常量。

#1


23  

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

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

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

或者使用常量文件(system / application / config / constants.php)来存储站点首选项常量。