在Codeigniter中使用require_once

7

如何在普通的PHP文件中在Codeigniter中使用require_once php函数?我目前遇到了一个错误。

代码:

require_once($_SERVER['DOCUMENT_ROOT'].'/php/jformer.php');

错误信息:

Message: require_once() [function.require-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0

Message: require_once(http://localhost/site/php/jformer.php) [function.require-once]: failed to open stream: no suitable wrapper could be found

2个回答

17

在这种情况下不应该使用 $_SERVER['DOCUMENT_ROOT'],而应使用 APPPATH 或者 BASEPATH,或者直接键入文件的完整路径。使用 require_once 时应该传递本地文件,而不是URL。


3
你应该使用文件路径而不是URL。最好(并且肯定符合CI规范)的方法是使用BASEPATHAPPPATH常量。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接