Recently in the company while writing a PHP program, because the company's operating efficiency requirements of the program is very high, but also a novice, the first attention to the efficiency of the program is very important, here on the combination of some information on the web, summed up under the PHP program efficiency optimization of some strategies:
 
1. When you can use file_get_contents instead of file, fopen, feof, Fgets and other series of methods, as far as possible with file_get_contents, because his efficiency is much higher! But be aware of the PHP version of file_get_contents when you open a URL file
 
2. As little as possible file operation, although the PHP file operation efficiency is not low;
 
3. Optimize select SQL statements, as little as possible in the case of INSERT, update operations (on the update, I was a bad batch);
 
4. Use PHP internal function as much as possible (but I am looking for a function that does not exist in PHP, wasting the time that can write a custom function, experience problem!) );
 
5. Do not declare variables inside the loop, especially large variables: objects (this seems to be not just a matter of note in PHP)? );
 
6. Multidimensional arrays as far as possible not to cycle nested assignment;
 
7. Do not use regular expressions when you can use PHP internal string manipulation functions;
 
8.foreach more efficient, try to use foreach instead of while and for loops;
 
9. Use single quotes instead of double quotes to quote strings;
 
10. "Replace I=i+1 with I+=1." In line with C + + habits, efficiency is also high ";
 
11. For global variables, you should unset () out