PHP Performance Efficiency optimization
Recently on the side of the company to write a PHP program, due to 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 is a combination of some information on the web, summarize 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, try to use file_get_contents, because his efficiency is much higher! But pay attention to the PHP version of file_get_contents when opening a URL file
2. As much as possible file operation, although PHP file operation efficiency is not low;
3. Optimize the Select SQL statement and make the INSERT and update operations as few as possible (on update, I was ill-approved);
4. Use PHP intrinsics as much as possible (but I'm wasting the time that could have written a custom function to find a function that doesn't exist in PHP, experience problem!) );
5. Inside the loop do not declare variables, especially large variables: objects (This is not just a question to be aware of in PHP?). );
6. Multidimensional arrays try not to loop nested assignments;
7. Do not use regular expressions in cases where PHP internal string manipulation functions are possible;
8.foreach more efficient, use foreach instead of while and for loops as much as possible;
9. Use single quotation marks instead of double quotation marks to reference strings;
10. "Replace I=i+1 with I+=1. In line with C + + habits, efficiency is high ";
11. For global variables, you should run out of unset ()
http://www.bkjia.com/PHPjc/629800.html www.bkjia.com true http://www.bkjia.com/PHPjc/629800.html techarticle PHP Performance Efficiency optimization recently in the company on the side of self-learning to write PHP program, because the company's operating efficiency requirements of the program is very high, and oneself is a novice, the first attention to the efficiency of the program is very ...