0

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

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by phplover
0

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.

0

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

0

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.

0

Thanks for your help, this has helped greatly :)

Thanks
PHPLOVER

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.