是否有可能我们可以制作自己的constants
,而不是在constants.php
文件夹中使用config
来完成工作?原因我想创建一些constants
,但是我的constants.php
太长了,我可以制作一个custom_constants.php
吗?
答案 0 :(得分:2)
在config.php
的底部,您可以输入:
require_once(APPPATH . 'some_folder/more_constants.php')
;
,它将在所有页面上为CodeIgniter实例加载。
请注意不要在application/config/constants.php
中重新定义任何CodeIgniter常量,否则您会收到通知。
此外,我认为您应该重新评估为什么有这么多常量。通常,常量仅用于路径和固定的var,因此我敢打赌,您只需创建一个新的配置文件并使用config类即可https://www.codeigniter.com/userguide3/libraries/config.html