1. If a method can be static, declare it static.
  2. echo faster than print.
  3. Transfer echo in several parameters, rather than to use the concatenation of the strings.
  4. Set the maximum number of passes for your cycles to cycle rather than while it is running.
  5. Remove your variables to free memory, especially if large amounts.
  6. Beware of magical techniques such as __set, __get, __autoload.
  7. require_once expensive.
  8. Specify the full path to the include / require structures, less time will be spent to search a file.
  9. If you need to determine the time when the script was run, use the $ _SERVER [ ‘REQUEST_TIME’] instead of time ().
  10. Try to use strncasecmp, strpbrk and stripos instead of regular expressions.
  11. str_replace faster than preg_replace, but strtr faster than str_replace.
  12. If the function as string replacement function, can take arguments as arrays and single characters, and if your argument list is not too long, consider the order to record multiple identical replacement expressions, passing one character at a time, instead of one line code that takes an array as an argument to search and replace
  13. It is better to choose a design assertion using else if, you can use several designs if.
  14. error suppression when using @ is very slow.
  15. Use Apache mod_deflate module.
  16. Close your database connections when you’re done working with them.
  17. $ Row [ ‘id’] seven times faster than $ row [id].
  18. Error messages are expensive
  19. Do not use functions inside of for loop conditions, for example like this: for ($ x = 0; $ x <count ($ array); $ x). In this case, the count () function will be called with each pass of the cycle.
  20. The growth rate of the local variable in the method – the fastest. Nearly also works increment a local variable in the function.
  21. The growth rate of the global variable is two times slower than a local.
  22. Increment properties of the object (ie $ this-> prop ++) is three times slower than a local variable.
  23. Increment uncertain variable is 9-10 times slower than a pre-initialized.
  24. Ad global variable without using it to function also slows down (about the same amount as that of the local variable increment). Probably, PHP checks for the existence of the variable.
  25. The speed of the method call, apparently, does not depend on the number of methods defined in the class. I added 10 methods in the test class (before and after the test method) with no change in performance.
  26. Methods in derived classes run faster than they’re defined in the base class.
  27. Calling a function with one parameter and an empty function body is equal to the average 7-8 increments a local variable ($ localvar ++). Call similar method, of course, about 15 increments.
  28. Your line defined with ‘instead of “will be interpreted a little faster because PHP searches for variables inside” .. “, but not” …’. Of course, you can use it only when your line no variables.
  29. The lines separated by commas, are displayed faster than the line, separated by a point. Note: This function only works with echo, which can take several strings as arguments.
  30. PHP-script to be processed, at least 2-10 times slower than static HTML-pages. Try to use more static HTML-pages and fewer scripts.
  31. Your PHP-scripts are recompiled every time unless the scripts are cached. Caching scripts usually increases performance by 25-100% by removing compile time.
  32. Cache as possible. Use memcached – a high-performance system caching objects in memory, which increases the speed of dynamic web applications due to the ease of uploading the database. Cached microcode is useful in that it allows your script is not compiled again for each request.
  33. When working with strings when you need to make sure that the string a certain length, of course you want to use the strlen () function. This feature is very fast, because it does not perform any calculation but merely return the already known length of a string available in the zval-structure (the internal structure of the C, used when working with variables in PHP). However because strlen () – a function, it will be slow due to the call of some operations, such as row reduction to lower case and search in a hash table, only after which will follow the basic steps function. In some cases, you can speed up your code through the use of tricks with isset ().
    It was: if (strlen ($ foo) < 5) {echo «Foo is too short »; }
    So: if (isset ($ foo {5})!) {Echo «Foo is too short»; }
    Calling isset () faster than strlen () because unlike strlen (), isset () – does not function as a language construct. Due to this, isset () has virtually no overhead to determine the length of the string.
  34. The increment or decrement a variable using $ i ++ happens a little slower than ++ $ i. This is a special specificity of PHP, and do not need to be modified so that your C and Java-code thinking that it will run faster, it will not happen. ++ $ I is faster in PHP because instead of four teams, as in the case of the $ i ++, you will need only three. Post-increment normally used when creating temporary variables, which are then increased. At that time, as a pre-increment increases the value of the original variable. This is one way the PHP-code optimization bytecode utility Zend Optimizer. Nevertheless, it is a good idea, because not all bytecode optimizers optimize it also remains a lot of scripts, working without optimization bytecode.
  35. Not everything has to be OOP, often it is unnecessary, since each method and object takes a lot of memory.
  36. Do not define every data structure as a class, arrays are very useful
  37. Not too smash methods. Think what you will really re-use.
  38. You can always break the code on the methods later, if necessary.
  39. Use the countless predefined functions.
  40. If your code has a function to perform very long, consider writing them as C extensions
(Visited 53 times, 1 visits today)
adminTips
If a method can be static, declare it static. echo faster than print. Transfer echo in several parameters, rather than to use the concatenation of the strings. Set the maximum number of passes for your cycles to cycle rather than while it is running. Remove your variables to free memory, especially if large...

Do you want to be notified about new DBA updates, releases, jobs and free tips? Join our email newsletter. It's fast and easy. You will be among the first to know about hot new DBA updates and stuff, it will help you enhance your DBA skills.
We take your privacy very seriously