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

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

问题描述

我是新的代码点火器。



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



在代码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');您可以使用配置文件( system /



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


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.

Where should I define globals in Code Igniter? 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');

解决方案

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.

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

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