Hi,

I want to know what you think is best for me to do.

I got a functions file that is included on every webpage on my website as it is in the top.inc.php file althou not all pages will use the functions file.

So my question is, should i include my functions file on pages that only need the functions file or leave it as it is? I am wondering see that would my functions file be processed still as it is currently included on every page even if any of the functions are not called on webpages that don't need the functions file?. I guess i want to know will i benefit more speed by only including on pages that need the file?. I use the require_once for the functions file in top.inc.php.

Thanks
PHPLOVER

Recommended Answers

All 5 Replies

If you have a function (definition) in the executable path of your code more than once you will get an error. If you will potentially have that situation and want to avoid the problem rather than re-engineer your code, use:

if (!function_exists(xxx) {
   function xxx( ) {
     ...
   }
}

wherever you have the definition of the Function. This will avoid the potential problem.

Hi,

I don't think i understand what you mean sorry.

I have been learning PHP on and off for past year and have progressed a huge deal but i am certainly not a pro either, althou i have built an entire membership website which works great. Could you possible explain in more depth and detail please if you don't mind?

I don't understand what you mean.

Thanks,
PHPLOVER

Sorry, I didn't read your question carefully enough. There will be some processing for the functions on every page that is executed. It is probably better to be consistent and include it everywhere unless it is really big. Even if that is the case, the performance difference probably won't be significant. If you have some pages that are executed very frequently and don't need any of the Functions, you could possible exclude the functions from that one and possibly put a note in the code as a reminder that they have been excluded.

If you just include them they'll not be called

Thanks for your help, this has helped greatly :)

Thanks
PHPLOVER

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.