homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP functions() best practice

 3:41 pm on Oct 21, 2002 (gmt 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)

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)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved