Glese Posted November 28, 2011 Share Posted November 28, 2011 I am trying to use absolute path across my project excluding the domain as of now and I am trying to do it as follows: define('root', '/php_projects/myproject/'); // The Standard Data $path = "path.php"; $connectvars = "connectvars.php"; // The CSS Styles $reset_css = root . "view/reset.css"; $style_css = root . "view/style.css"; This works so far, the only problem I am having is that it is producing a notice. And my question is, how can I get rid of the notice? The notice is this one: Notice: Constant root already defined in C:\xampp\htdocs\php_projects\myproject\path.php on line 3 Why does the notice get produced in first place? I never defined it twice, as it states. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/ Share on other sites More sharing options...
trq Posted November 28, 2011 Share Posted November 28, 2011 You *are* defining the same constant twice. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291794 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 I am not understanding, how am I defining it twice, I am trying to use it, or do you mean because I use it inside a variable. What would you recommend me to accomplish what I am trying to accomplish? Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291795 Share on other sites More sharing options...
trq Posted November 28, 2011 Share Posted November 28, 2011 Somewhere in your code you are defining the constant "root" twice. What is on line 3 of path.php ? Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291797 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 What you are seeing is path.php, it is impossible that I am defining it twice, I just typed it neweley, it must be a fatal mistake apocalypse. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291801 Share on other sites More sharing options...
trq Posted November 28, 2011 Share Posted November 28, 2011 Is this path.php file being included into another file? Notices are generally human error. One hack would be to check that it's not already defined before trying to define it again, but yeah, you really should know wether or not you have already defined something. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291803 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 The path.php file gets included into the header.php file, and from there on I am using variables for every path on the whole project MVC style. But other than the header.php I do not include it any where. You mentioned a check, is there any specific way to do it. Other than that I will try to define it directly in the header.php file and see if that will work. EDIT: Putting the define function inside of header.php file did solve it, keep in mind that I did not define it twice though, I assume it may have become reloaded twice. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291809 Share on other sites More sharing options...
trq Posted November 28, 2011 Share Posted November 28, 2011 keep in mind that I did not define it twice though, I assume it may have become reloaded twice. Loading the definition twice *IS* defining it twice. Programming is an exact science, if you do something wrong, things break. It's doesn't matter how small the detail. Quote Link to comment https://forums.phpfreaks.com/topic/251954-define-function-notice/#findComment-1291811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.