docs:programming:php:optimizing_execution_time

Optimizing Execution Time

  • avoid printf() when echo is all you need
  • avoid recomputing values inside a loop
    • don't do this:
      for($i=0; $i < count($array); $i++) {/* do something */}
    • instead, do this:
      $num = count($array);
      for($i=0; $i < $num; $i++) { /* do something */ }
  • include only files that you need; split the functions into more files if they are not always used together
  • if using a database, use persistent connections
  • don't use a regular expression when a simple string-manipulation function will do the job; for example, to turn one character into another in a string, use str_replace(), not preg_replace().
  • docs/programming/php/optimizing_execution_time.txt
  • Last modified: 2008/08/03 00:25
  • by 127.0.0.1