Tips for sharing php performance Optimization _php Tutorial

Source: Internet
Author: User

"Replace i=i+1 with I+=1." In line with C + + habits, efficiency is high ";

For global variables, you should run out of unset ()

As far as possible to file operations, although the PHP file operation efficiency is not low;

Optimization of the Select SQL statement, as far as possible in the case of INSERT, update operation (on the update, I was bad batch) to achieve the purpose of PHP performance optimization;

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!);

In the case can be replaced with file_get_contents 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 file_get_ Contents PHP version problem when opening a URL file;

Inside the loop, do not declare variables, especially large variables: objects (This is not just a question to be aware of in PHP?);

Multidimensional arrays try not to loop nested assignments;

Do not use regular expressions in cases where PHP internal string manipulation functions are possible;

foreach is more efficient and uses foreach instead of while and for loops as much as possible.

Use single quotes instead of double quotation marks to reference strings for PHP performance optimization;

In multiple nested loops, if possible, the longest loop should be placed in the inner layer, with the shortest loop in the outer layers, thus reducing the number of times the CPU crosses the loop layer to optimize program performance.


http://www.bkjia.com/PHPjc/445982.html www.bkjia.com true http://www.bkjia.com/PHPjc/445982.html techarticle replace i=i+1 with I+=1. In line with the C + + habit, the efficiency is high; For the global variable, you should run out of unset () as much as possible to file operations, although PHP file operation efficiency is not low; Excellent ...

  • 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.