01 November, 2009

Php code optimization tips

Here are some tips and explanations about php code optimization.
  1. Use echo instead of print.
  2. Use single('') quotes instead of double(""). Double quotes search for variables in string.
  3. Declare static variables if possible.
  4. Use echo’s multiple parameters instead of string concatenation("." instad of ",").
  5. ++$i is faster than $i++.
  6. Define your variables, using static and global.
  7. Unset or null large variables.
  8. Use absolute paths in includes and requires.
  9. Use "else if" statements instead of "switch/case"
  10. Error suppression with @ is very slow.
  11. Use tags when declaring PHP as all other styles are depreciated, including short tags.

I will improve this list if I will find out new improvements.

No comments:

Post a Comment