Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP functions() best practice

3:41 pm on Oct 21, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 6, 2001
votes: 0

Having just got my first home made function to work in php and mysql (nifty concept) I have a question about performance if I may.

Should I create a huge one size fits all external library of functions that is called whenever I need to perform one of them or split them down into cateogories. My musings are such:

If I call the large file it will slow the page down as it has to go through hundreds of lines of code. Is this a correct assumption.

When does an include become a class? Or am I barking up the wrong tree etirely?

Any help appreciated

3:55 pm on Oct 21, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 12, 2002
votes: 0

I'm not 100% certain, since I haven't benchmarked it, but my assumption has always been that even if I didn't noticably slow down the server, loading lots of unnecessary functions from an include file would raise the memory requirements of my scripts unnecessarily.

As for classes, code becomes a class when it is declared as such, eg,

class MyClass
var myFirstProperty;
var mySecondProperty = "bar";

function MyFirstMethod($arg)
return $arg * $arg;

Sort of a useless class as written, but you get the idea. There's plenty of info in the manual at www.php.net to get you started with objects and classes in PHP.

4:27 pm on Oct 21, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:May 2, 2002
votes: 0

Good question, I've never checked if there is a significant performance hit, but my practise is to have 2 or 3 separate function files according to the use: e.g. admin, user and common functions.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members