Ravens PHP Scripts

50+ PHP optimisation tips revisited
Date: Friday, May 20, 2011 @ 01:13:35 PDT
Topic: PHP


Enjoy!

1. echo is faster than print.
2. Wrap your string in single quotes (') instead of double quotes (") is faster because PHP searches for variables inside "" and not in '', use this when you're not using variables you need evaluating in your string.
3. Use sprintf instead of variables contained in double quotes, it's about 10x faster.
4. Use echo's multiple parameters (or stacked) instead of string concatenation.
5. Use pre-calculations, set the maximum value for your for-loops before and not in the loop. ie: for ($x=0; $x 6. Unset or null your variables to free memory, especially large arrays.
7. Avoid magic like __get, __set, __autoload.
8. Use require() instead of require_once() where possible.
9. Use full paths in includes and requires, less time spent on resolving the OS paths.
10. require() and include() are identical in every way except require halts if the file is missing. Performance wise there is very little difference.


more with citations: hm2k Internet Engineering








This article comes from Ravens PHP Scripts
http://www.ravenphpscripts.com

The URL for this story is:
http://www.ravenphpscripts.com/modules.php?name=News&file=article&sid=3937