jenniferG Posted September 7, 2007 Share Posted September 7, 2007 we have a project that use a small include 'stuff.php'; The include statement is in many of there files in the project and we get errors from function definitions beoing duplicated. Is the include opnce the way around this, so if we put this in one script, other scripts that are transferred to will be able to use functons wiothout interference, and two-is there a php function that we can tell if an include file is actuially included? Thanks, Melanie Quote Link to comment https://forums.phpfreaks.com/topic/68418-include-once/ Share on other sites More sharing options...
lemmin Posted September 7, 2007 Share Posted September 7, 2007 Yes, and if the file was successfully included, it will return true. Quote Link to comment https://forums.phpfreaks.com/topic/68418-include-once/#findComment-343986 Share on other sites More sharing options...
noidtluom Posted September 8, 2007 Share Posted September 8, 2007 Well for your second question, what I would do (which is pretty unorthodox) is after an include, set a variable or constant. For example: if($incMyFile!=1) { include_once 'myfile.php'; $incMyFile=1;} I don't know of a function sorry. EDIT: oh, especially if your included file defines constants or important variables, just do if MYIMPORTANTCONSTANT is defined then don't include it the next time. Quote Link to comment https://forums.phpfreaks.com/topic/68418-include-once/#findComment-344206 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.