PHP Performance Efficiency Optimization _php Tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.