I’m using constants to set various configuration variables within a script.
The INC_PATH constant is defined within the script that includes the class library.
define('INC_PATH',$_SERVER['DOCUMENT_ROOT'].'includes/');
include('class.lib.php');
The class library contains various include(‘someClass.php’) lines. It also contains:
require(INC_PATH.'DB.class.php');
The class library throws a notice:
Use of undefined constant INC_PATH - assumed 'INC_PATH'
How is the class library not able to see that the INC_PATH constant has been defined? I thought constants were global?
Yes, but they must be defined before:
In response to your comment
I can’t reproduce that:
a.php
b.php.inc
c.php.inc
Asking for
a.phpgives: