The following summarizes the 18 PHP code can be done in writing optimization habits, in order to maximize the speed of the implementation of PHP code!
(1) uses static static Method 4 times times faster than normal method
(2) Echo output faster than print
(3) The connection character is used instead.
(4) Take out the maximum value before the loop, not the value in the loop
The right way
$max = count ($array);
for ($i =0; $i < $max; $i + +) {
echo $i;
}
The wrong way
for ($i =0; $i
echo $i;
}
(5) Use unset to release a given variable
(6) Includes and requires include file use full path
(7) Use STRNCASECMP, strpbrk and stripos instead of regex
(8) using switch instead of if Else statement
(9) Suppress error symbol @ Low performance
(10) Remember to close unwanted database connections at any time
(one) $row [' ID '] 7 times faster than $row [ID] Performance
(12) Adding a global variable is twice times slower than adding a local variable
(13) Use single quotes instead of double quotation marks to reference characters
(14) Use HTML 2-20 times faster than PHP scripts
(15) Use PHP cache to accelerate performance 25%-100%
(16) $++ $i slower than + +
(17) Do not overuse oop, moderate
(18) Use PHP built-in functions as much as possible
If there's a supplement, you're welcome to join.
http://www.bkjia.com/PHPjc/735171.html www.bkjia.com true http://www.bkjia.com/PHPjc/735171.html techarticle The following summarizes the 18 PHP code can be done in writing optimization habits, in order to maximize the speed of the implementation of PHP code! (1) using static Statics Method 4 times times faster than normal method ( ...