Re: [PHP] Includes only if required?
On Mon, Feb 2, 2009 at 6:42 AM, Edmund Hertle farn...@googlemail.com wrote: Hey, normally I prefer to do all my includes (classes + config files) at the beginning if my php files. But recently I thought about including some classes only if they are needed later in my code (like pear Mail and Mail_mime only if an e-mail is about to be sent) because of speed issues. So my question: Is this something I should consider? Or is it something I normally will not notice? -eddy Look at spl_autoload_register. -- http://www.voom.me | EFnet: #voom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Includes only if required?
Hey, normally I prefer to do all my includes (classes + config files) at the beginning if my php files. But recently I thought about including some classes only if they are needed later in my code (like pear Mail and Mail_mime only if an e-mail is about to be sent) because of speed issues. So my question: Is this something I should consider? Or is it something I normally will not notice? -eddy
Re: [PHP] Includes only if required?
Hi, Mail_mime Ooh... only if an e-mail is about to be sent) because of speed issues. So my question: Is this something I should consider? Or is it something I normally will not notice? Depends on the load on your server. If you're getting a billion requests per second, then it may well be cause for concern. Either way you can define a function called __autoload that gets called when a class is about to be instantiated. This function can then load the correct library. On demand as it were. http://uk2.php.net/__autoload -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 31st) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php