Welcome to WebmasterWorld Guest from 107.21.175.43

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP functions() best practice

     

ukgimp

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

WebmasterWorld Senior Member 10+ Year Member



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

dingman

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

WebmasterWorld Senior Member 10+ Year Member



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.

transistor

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

10+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month