First, the basic knowledge of PHP itself, functions, constants, and so on, as far as possible to solve this problem with the built-in method (because the individual writing often run efficiency is not built-in method high);
Second, the code as little as possible to achieve the function (because the PHP operation is in fact, will our code first processed into the underlying language for the machine to run, assuming that the code is many, the content of the conversion more natural time-consuming);
Third, the optimization can be measured by the pressure test AB test their own code, and the code optimization, again pressure measurement efficiency;
Four, less with the @ symbol;
Use the unset () function more than five. The variable is written off and released;
Six, the less use of the form, double-edged sword;
Seven, avoid the loop for the loop condition to do the operation;
Eight, the key value of the array, be sure to use the quoted string as the key value, why do you have to do this?
When $arr = Array ("key" = "hehe"); $arr ["Key"] is correct, efficiency-enhancing
$arr [key] does not have an argument, it is not good, due to PHP runtime. Found key without an argument
At this point, he will check to see if the key is a constant. If you turn on the error mechanism, you will be prompted notice
The constant is not found for key.
Assuming that the argument is added, PHP will go directly to the $arr array to find the key value for key.
relative efficiency is efficient.
Ix. external factors that affect PHP performance are:
The inspiration for this point is that when a site is very slow. Perhaps not the performance of PHP itself is slow, may be a network problem, may be a hardware problem, etc., as an architect to troubleshoot the problem can not stay in the program optimization!
It is more efficient to read the contents of memory than to read the contents of the database. So the large-volume speed-up site often uses memcache, Redis and other distributed caches to cache data to memory. Then the data is read with the memory first.
Xi. through Xhporf (from the Facebook Test PHP Performance analysis tool). Ability to test the process of visiting the site. and can through the flow chart red area high-speed find, time-consuming method, the method optimization can be;
PHP Development Work Experience