high priority

  1. Turn on apache's mod_deflate . it will reduce the data to transfer up to 80%.ther's a CPU cost, thats why dfault is compression 6 over max 9. AddOutputFilterByType DEFLATE application/javascript text/css
  2. Install APC to increase performance by 25-100% by removing compile times
  3. sending gz-encoded data to web browsers that support compressed web pages via ob_gzhandler()
  4. Do use error_reporting (E_ALL); during debug.
  5. Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview

marginal gains

filesystem:

  1. require_once() is expensive
  2. Use full paths in includes and requires, less time spent on resolving the OS paths.
  3. Do use full file paths in production environment over basename/fileexists/open_basedir to avoid performance hits for the filesystem having to hunt through the file path. Once determined, serialize and/or cache path values in a $_SETTINGS array. $_SETTINGS["cwd"]=cwd(./);
  4. Do use require/include over require_once/include_once to ensure proper opcode caching.
  5. Do serialize application settings like paths into an associative array and cache or serialize that array after first execution.

objects:

  1. If a method can be static, declare it static. Speed improvement is by a factor of 4.
  2. Unset your variables to free memory, especially large arrays.
  3. Avoid magic like get, set, __autoload

loops:

  1. Set the maxvalue for your for-loops before and not in the loop.
  2. Do use foreach for looping collections/arrays.
  3. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.

strings:

  1. echo is faster than print. Use echo's multiple parameters instead of string concatenation.
  2. Do use single quotes over double quotes.
  3. See if you can use strncasecmp, strpbrk and stripos instead of regex
  4. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4

etc:

  1. Error suppression with @ is very slow.
  2. Close your database connections when you're done with them
  3. If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time()
  1. Do use ctype_alnum,ctype_alpha and ctype_digit over regular expression to test form value types for performance reasons.
  1. Do use POST over GET for all values that will wind up in the database for TCP/IP packet performance reasons.
  1. Do use PDO prepare over native db prepare for statements. mysql_attr_direct_query=>1
  2. Do NOT use SQL wildcard select. eg. SELECT *
  1. Do set Apache allowoverride to "none" to improve Apache performance in accessing files/directories.

Notice: Undefined variable: browserName in /var/www/taziomirandola.it/lib/Visitors.php on line 86

Notice: Undefined variable: browserName in /var/www/taziomirandola.it/lib/Visitors.php on line 96

Deprecated: strripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /var/www/taziomirandola.it/lib/Visitors.php on line 96

Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /var/www/taziomirandola.it/lib/Visitors.php on line 39

Fatal error: Uncaught TypeError: Argument 1 passed to safe_text() must be of the type string, null given, called in /var/www/taziomirandola.it/lib/Visitors.php on line 39 and defined in /var/www/taziomirandola.it/lib/Visitors.php:162 Stack trace: #0 /var/www/taziomirandola.it/lib/Visitors.php(39): safe_text() #1 /var/www/taziomirandola.it/lib/Visitors.php(124): Visitors::getData() #2 [internal function]: Visitors::log() #3 {main} thrown in /var/www/taziomirandola.it/lib/Visitors.php on line 162