本文介绍了Codeigniter:当在“application / config / constants.php”文件中使用base_url()函数定义一个常数时,会发生致命错误。文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我使用Codeigniter,现在我试图定义一些常量来保存一些文件夹,如css,js,图像等的完整路径,我试图定义这些常量在 application / config / constants.php 文件如下:I'm using Codeigniter and right now I'm trying to define some constants to hold full paths to some folders like css, js, images, etc. and I've tried to define these constants in application/config/constants.php file like this:define("PATH_TO_CSS_FOLDER", base_url("assets/css"));但我遇到此错误:Fatal error: Call to undefined function base_url() in D:\xampp\htdocs\demo\application\config\constants.php on line 44,因此如何定义这些常量,而不必在constants.php文件中写入绝对路径,如下所示: so how can I define these constants without having to write the absolute path in the constants.php file like this:define("PATH_TO_CSS_FOLDER", "http://my-website.com/assets/css"); 推荐答案可以在constant.php you can define rest of path in constant.php define("PATH_TO_CSS_FOLDER","assets/css");稍后再次使用它<?php echo base_url(PATH_TO_CSS_FOLDER);?>您可能知道常数首先加载任何辅助程序you might be knowing that constants loads first then any helper 这篇关于Codeigniter:当在“application / config / constants.php”文件中使用base_url()函数定义一个常数时,会发生致命错误。文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 12:42