Summary of php code writing habits optimization. (1) static method is 4 times faster than normal method (2) echo output is faster than print (3) connection character usage, instead. (4) retrieve the maximum value before the loop, instead of in the loop (1) use the static method four times faster than the normal method
(2) echo output is faster than print
(3) use the connection character instead.
(4) take the maximum value before the loop, instead of taking the value in the loop.
Correct Method
$ Max = count ($ array );
For ($ I = 0; $ I <$ max; $ I ++ ){
Echo $ I;
}
Incorrect method
For ($ I = 0; $ I Echo $ I;
}
(5) use unset to release a given variable
(6) use the complete path for the files contained in includes and requires
(7) replace regex with strncasecmp, strpbrk, and stripos
(8) replace if else statement with switch
(9) suppress error characters @ low performance
(10) remember to close unnecessary database connections at any time
(11) $ row ['id'] is 7 times faster than $ row [id]
(12) adding a global variable is twice slower than adding a local variable.
(13) use single quotes instead of double quotes to reference characters
(14) using HTML is 2-20 times faster than PHP scripts
(15) PHP Cache accelerates performance by 25%-100%
(16) $ ++ is slower than ++ $ I
(17) do not over-use OOP.
(18) use PHP built-in functions whenever possible
Http://www.bkjia.com/PHPjc/327732.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327732.htmlTechArticle (1) using static method is 4 times faster than normal method (2) echo output is faster than print (3) connection character use, instead. (4) take the maximum value before the loop, instead of in the loop...