I'm new to PHP. I've been looking at the documentation and am having a problem. I have a multi-page PHP site I am working on. I was having a problem with relative paths (PHP Relative Path Issues) and was pointed to the following url(PHP include relative path). I want to use something similar to the following code snippet in the post:
if (is_production()) {
define('ROOT_PATH', '/some/production/path');
}
else {
define('ROOT_PATH', '/root');
}
include ROOT_PATH . '/connect.php';
On what page do I add the define statement (index.php?) and how can I reference the ROOT_PATH on every subsequent page that has an include statement?
I tried adding the define statement to the index.php page but calling the ROOT_PATH on any other page results in: Use of undefined constant ROOT_PATH
Index.php: define('ROOT_PATH', '/some/production/path');
some other page: include_once(ROOT_PATH."/Library/API/database.inc.php");