Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using require_once in Codeigniter

How do I use the require_once php function in Codeigniter on a normal PHP file? I', currently getting an error.

Code:

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(http://localhost/site/php/jformer.php) [function.require-once]: failed to open stream: no suitable wrapper could be found

like image 436
Nyxynyxx Avatar asked Jul 18 '11 15:07

Nyxynyxx


2 Answers

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.

like image 112
Rocket Hazmat Avatar answered Oct 02 '22 21:10

Rocket Hazmat


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.

like image 31
Anshuman Avatar answered Oct 02 '22 20:10

Anshuman