Since phpBB inspired me to start learning PHP, and eventually starting my own business as a programmer, I might aswell post this here.
I'm developing a CMS right now with a lot or functions similar to the ones used in phpBB, such as an advanced template parser, BBCode, search engine, etc.. I already integrated some functionality which I 'stole' from this new version in development. The devs here are way ahead of me though, they managed to keep the board up to speed by caching templates for instance.
Now I wonder, what can I do to speed up my scripts? What slows them down (although my average parse time is about the same as it is here)? Should I store image info in the DB and not in a file? Should I use less preg_replace() functions? Any ideas would be more then welcome!
Any tips for speeding up PHP scripts..?
Forum rules
Please do not post any "phpBB" specific topics here unless they do not fit into the category above.
Do not post bug reports, feature or support requests! No really... Do not post bug reports, feature or support requests! Doing so will make Bertie a very sad bear indeed. :(
Please do not post any "phpBB" specific topics here unless they do not fit into the category above.
Do not post bug reports, feature or support requests! No really... Do not post bug reports, feature or support requests! Doing so will make Bertie a very sad bear indeed. :(
-
- Registered User
- Posts: 397
- Joined: Tue Jul 20, 2004 6:21 am
- Location: Rotterdam, The Netherlands
- Contact:
Re: Any tips for speeding up PHP scripts..?
first- reduce the total queries as much as you can.
second - preg_replace > str_replace, this simply replaces it immediately, str_replace first looks and then replaces. + Regex are sweet ( BBCode, Smilleys etc. )
third - caching is a good one, rather hard to apply correct though.
fourth - sessions, try to use the least possible amount of sessions. although this is better then cookies- cookies are evil itself !
fifth - OOP. object orientated programming- this cuts down a lot- since it only uses whats needed, nothing more and nothing less
sixth - try to create normalised databases ( whats it called in EN? ) relational etc.. LEFT and RIGHT joins
seventh - try not to overdo on total code- the more code thats required, the longer it takes. IE working with vars.
hope it helps
second - preg_replace > str_replace, this simply replaces it immediately, str_replace first looks and then replaces. + Regex are sweet ( BBCode, Smilleys etc. )
third - caching is a good one, rather hard to apply correct though.
fourth - sessions, try to use the least possible amount of sessions. although this is better then cookies- cookies are evil itself !
fifth - OOP. object orientated programming- this cuts down a lot- since it only uses whats needed, nothing more and nothing less
sixth - try to create normalised databases ( whats it called in EN? ) relational etc.. LEFT and RIGHT joins
seventh - try not to overdo on total code- the more code thats required, the longer it takes. IE working with vars.
Code: Select all
// this method is a bit.. useless, since it takes up memory- which in turn takes speed
$var = $_POST['var'];
$_SESSION['var'] = $var;
// this method however- cuts back a little- but count each time you do this, and you [b]will[/b] notice quite a change
$_SESSION['var'] = $_POST['var'];
// only use the first method if you want to apply some functions to it
hope it helps
Re: Any tips for speeding up PHP scripts..?
http://www.lerdorf.com/tips.pdf" target="_blank
http://www.php.lt/benchmark/phpbench.php" target="_blank
http://phplens.com/lens/php-book/optimi ... ng-php.php" target="_blank
Just a few I have found rather useful...
Yawnster
http://www.php.lt/benchmark/phpbench.php" target="_blank
http://phplens.com/lens/php-book/optimi ... ng-php.php" target="_blank
Just a few I have found rather useful...
Yawnster
Re: Any tips for speeding up PHP scripts..?
Thanks, that's very useful
I didn´t find the article on phplens.com very useful (I´ve read it before), since my sites usually aren´t hosted on my own server and I don´t have any influence on that. But foreach() vs. while(list()=each()) etc. is pretty interesting
I didn´t find the article on phplens.com very useful (I´ve read it before), since my sites usually aren´t hosted on my own server and I don´t have any influence on that. But foreach() vs. while(list()=each()) etc. is pretty interesting
Re: Any tips for speeding up PHP scripts..?
There are at least 2 different PHP accelerators that can be installed on a server. I'm not sure what they are called, but someone else may know.
Re: Any tips for speeding up PHP scripts..?
Like Zend? Anyway, as I said I'm only interested in optimising my programming right now..
-
- Registered User
- Posts: 32
- Joined: Mon Oct 27, 2003 4:48 pm
Re: Any tips for speeding up PHP scripts..?
optimize that code!