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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.