kenoli Posted March 10, 2021 Share Posted March 10, 2021 I have defined my database connection data as constants in a separate file for security reasons. How can I simply access the data stored in those constants. I have to call the file to get the value of the constants. If I inadvertently call the file twice in a script using an include or require statement, I get an error that I am trying to define the constants again. Can I somehow just call the constants without including the file where they are defined? --Kenoli Quote Link to comment https://forums.phpfreaks.com/topic/312271-accessing-user-defined-constants/ Share on other sites More sharing options...
gw1500se Posted March 10, 2021 Share Posted March 10, 2021 (edited) Use the correct require statement. Edited March 10, 2021 by gw1500se Quote Link to comment https://forums.phpfreaks.com/topic/312271-accessing-user-defined-constants/#findComment-1584991 Share on other sites More sharing options...
Barand Posted March 10, 2021 Share Posted March 10, 2021 or make use of the defined() function Quote Link to comment https://forums.phpfreaks.com/topic/312271-accessing-user-defined-constants/#findComment-1584994 Share on other sites More sharing options...
benanamen Posted March 10, 2021 Share Posted March 10, 2021 Sounds to me like you have an Architecture problem. You "should" be serving all your files through a single point of entry. You might want to start a new thread about that topic with details of how you have things set up. Quote Link to comment https://forums.phpfreaks.com/topic/312271-accessing-user-defined-constants/#findComment-1584995 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.