php 在 Codeigniter 中使用 require_once
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6734976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using require_once in Codeigniter
提问by Nyxynyxx
How do I use the require_once
php function in Codeigniter on a normal PHP file? I', currently getting an error.
如何require_once
在普通 PHP 文件上使用Codeigniter 中的php 函数?我',目前出现错误。
Code:
代码:
require_once($_SERVER['DOCUMENT_ROOT'].'/php/jformer.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/php/jformer.php');
Error:
错误:
Message: require_once() [function.require-once]: http:// wrapper is disabled in the server configuration by allow_url_include=0
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
Message: require_once(http://localhost/site/php/jformer.php) [function.require-once]: failed to open stream: no suitable wrapper could be found
回答by Rocket Hazmat
You don't use $_SERVER['DOCUMENT_ROOT']
for this, you want to use APPPATH
or BASEPATH
instead, or just type the full path to the file. require_once
should be passed a local file, not a URL.
你不使用$_SERVER['DOCUMENT_ROOT']
这个,你想使用APPPATH
orBASEPATH
代替,或者只是输入文件的完整路径。 require_once
应该传递一个本地文件,而不是一个 URL。
回答by Anshuman
You should be using the path to the file and not the URL. Best (and certainly CI friendly) way would be to use BASEPATH
or APPPATH
constants.
您应该使用文件的路径而不是 URL。最好的(当然也是 CI 友好的)方法是使用BASEPATH
或APPPATH
常量。