Jiire Ige Damola
Jiire Ige Damola

Reputation: 5

Including files with php include function not working on my system

I was trying to include a php file with the code

include "$_SERVER[DOCUMENT_ROOT]/inc/file.php";

The error i was getting is

Warning: include() [function include]: unable to access C:/wamp/www/inc/file.php on line 6
Warning include(C:/...... Failed to open stream no error.

And i tried to use require_once; the error was the same my php version is 5.2

Upvotes: 0

Views: 156

Answers (3)

danc403
danc403

Reputation: 84

set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER[DOCUMENT_ROOT]/inc);
include "$_SERVER[DOCUMENT_ROOT]/inc/file.php";

Upvotes: 0

Basic Bridge
Basic Bridge

Reputation: 1911

Use this

include $_SERVER['DOCUMENT_ROOT'].'/inc/file.php';

Upvotes: 1

Winston
Winston

Reputation: 1805

include dirname(__FILE__) . '/inc/file.php';

Upvotes: 1

Related Questions