Jump to content

include once


jenniferG

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/68418-include-once/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/68418-include-once/#findComment-344206
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.