1. If a method can be static, declare it static. Speed improvement.
2. str_replace is faster than preg_replace, but strtr is faster than str_replace .
3. $row['id'] is 7 times faster than $row[id] , because if you don't supply quotes it has to guess which index you meant, assuming you didn't mean a constant.
4. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.
5. echo is faster than print
6. Unset or null your variables to free memory, especially large arrays.
7. Use require () instead of require_once() where possible.
8. Use absolute paths in includes and requires. It means less time is spent on resolving the OS paths.
include('/var/www/html/your_app/test.php');
//is faster than
include('test.php');
9. require () and include() are identical in every way except require halts if the file is missing. Performance wise there is very little difference.
10. "else if" statements are faster than "switch/case" statements.
11. Error suppression with @ is very slow.
if (isset($albus)) $albert = $albus;
else $albert = NULL;
//is faster than
$albert = @$albus;
12. Never trust variables coming from users (such as from $_POST) use mysql_real_escape_string when using mysql, and htmlspecialchars when outputting as HTML
13. Use <?php ... ?> tags when declaring PHP as all other styles are depreciated, including short tags.
14. Avoid using plain text when storing and evaluating passwords. Instead use a hash, such as an md5 hash.
15. Use ip2long () and long2ip() to store IP addresses as integers instead of strings.
16. Do not implement every data structure as a class, arrays are useful, too
17. 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.
18. Since PHP5, the time of when the script started executing can be found in $_SERVER['REQUEST_TIME'], use this instead of time() or microtime().
19. Close your database connections when you're done with them.
20. Learn the difference between good and bad code.
21. Stick to coding standards, it will make it easier for you to understand other people's code and other people will be able to understand yours.
22. Separate code, content and presentation: keep your PHP code separate from your HTML.
23. Methods in derived classes run faster than ones defined in the base class.