Is defining contants is php version dependent?
Posted: Fri Jun 13, 2008 3:53 pm
Hi everybody,
I have some classes in one php file that I will use in many other php files. I am facing a problem which is the path to the folder that contains the classes. I get a suggestion to use constants.
I have placed the following line in html_generator_classes.php file:
define("HTML_GENERATOR_CLASSES", dirname(__FILE__)."\html_generator_classes.php");
Then I tried to use it in any require/ include directives in other php files like the following:
include HTML_GENERATOR_CLASSES;
It didn't work! I am getting:
PHP Notice: Use of undefined constant HTML_CLASSES - assumed 'HTML_CLASSES' in ....
I read that defining a constant will make it global and can be used from any php file within the application. Or I might misunderstood the concept of constants?
Can anyone please explain to me what went wrong?
Note: I am using Eclipse 3.3 PDT, and it lists the new defined constant in the project outline, and it is suggested using code assistant (by writing the 1st letter then Ctrl+space). But still I am getting the above mentioned error when testing the file on the IE browser.
I have some classes in one php file that I will use in many other php files. I am facing a problem which is the path to the folder that contains the classes. I get a suggestion to use constants.
I have placed the following line in html_generator_classes.php file:
define("HTML_GENERATOR_CLASSES", dirname(__FILE__)."\html_generator_classes.php");
Then I tried to use it in any require/ include directives in other php files like the following:
include HTML_GENERATOR_CLASSES;
It didn't work! I am getting:
PHP Notice: Use of undefined constant HTML_CLASSES - assumed 'HTML_CLASSES' in ....
I read that defining a constant will make it global and can be used from any php file within the application. Or I might misunderstood the concept of constants?
Can anyone please explain to me what went wrong?
Note: I am using Eclipse 3.3 PDT, and it lists the new defined constant in the project outline, and it is suggested using code assistant (by writing the 1st letter then Ctrl+space). But still I am getting the above mentioned error when testing the file on the IE browser.