Jump to content

[SOLVED] Most Efficient/Effective way to include functions


rtadams89

Recommended Posts

Hello all. Let me start by saying I have searched for this, but have not found a satisfactory answer. Probably because I am unsure of exactly what to search for.

 

I have a website with 10+ PHP pages. There are some functions that every page uses, some functions that a few of the pages use, and some functions that only get used on one page. Currently, all of these functions are in a file named "functions.php" which is 40KB in size. As the first line of all my content PHP pages, I have included

<?require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');?>

to ensure these functions are available on each page.

 

Is this appropriate? Would it be better to have separate function files which contain "groups" of related functions, and then only include those "groups" that are needed on the particular page? Does including one large function file on every page perform better than including several smaller files on some pages?

Link to comment
Share on other sites

Awesome. At point should I worry about using separate include files?

 

@redarrow: What would be the advantage of using the "include_once()" or "require_once()"? Since I am including the file at the top of the page, there doesn't seem to be a way for it to ever be accidentally loaded again...

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.