Although the PHP language function is powerful, but also needs the programmer to write the specification, creates the performance superior code program. Here we share PHP's performance optimization techniques.
"Replace i=i+1 with I+=1." In line with C + + habits, efficiency is also high ";
For global variables, you should run out of unset ()
As little as possible to file operations, although the PHP file operation efficiency is not low;
Optimize the Select SQL statement and, if possible, minimize the INSERT, update operation (on update, I was bad batch) to achieve the purpose of PHP performance optimization;
Use PHP's internal functions as much as possible (but I've wasted the time and experience of writing a custom function in order to find a function that doesn't exist in PHP);
In the case of using file_get_contents instead of file, fopen, feof, fgets, and so on, try to use file_get_contents, because he is much more efficient! But pay attention to file_get_ Contents PHP version problem when opening a URL file;
Inside the loop do not declare variables, especially large variables: objects (this seems to be not just a matter of note in PHP?);
Multidimensional arrays do not loop nesting assignments as much as possible;
Do not use regular expressions when you can use PHP internal string manipulation functions;
foreach is more efficient and uses foreach instead of while and for loops as much as possible; (www.3lian.com)
Use single quotes instead of double quotes to quote strings for PHP performance optimization;
In multiple nested loops, if possible, the longest loop should be placed in the inner layer, and the shortest loop should be placed at the outer level, which can reduce the number of times the CPU spans the loop layer, thereby optimizing program performance