I know I’m doing something stupid and probably obvious, but I’m not sure what. In my header.php I have:
define('ABSPATH', $_SERVER['SERVER_NAME']);
require_once(ABSPATH . "/config.php");
Using this produces the following error:
Warning: require_once(localhost/config.php): failed to open stream:
No such file or directory in C:\wamp\www\inc\header.php on line 4
Call Stack: 0.0002 684176 1. {main}() C:\wamp\www\index.php:0 0.0003
696152 2. require_once('C:\wamp\www\inc\header.php') C:\wamp\www\index.php:2
Fatal error: require_once(): Failed opening required 'localhost/config.php' (include_path='.;C:\php\pear') in C:\wamp\www\inc\header.php on line 4 Call Stack:
0.0002 684176 1. {main}() C:\wamp\www\index.php:0 0.0003 696152 2. require_once('C:\wamp\www\inc\header.php') C:\wamp\www\index.php:2
However, if I navigate directly to localhost/config.php (currently, it’s just a simple 1 line file that is echoing a sentence) It will work.
What am I doing wrong?
$_SERVER['DOCUMENT_ROOT']should do the trick