PHP Performance Efficiency optimization

Source: Internet
Author: User
1, in the case can be used file_get_contents alternative File,fopen,feof,fget series of methods, as far as possible to use the feil_get_contents, because it is much more efficient! But pay attention to the PHP version of file_get_contents when you open the URL file

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

3, optimize the Select SQL statement, as little as possible insert,update operation

4, use PHP intrinsics as much as possible (experience problem, don't waste time looking for PHP internal function,)

5, do not declare variables in the mixed, especially large variables,

6, multidimensional arrays try not to iterate over nested assignments

7, do not use regular expressions in cases where you can manipulate functions with PHP internal characters

8,foreach is more efficient, use foreach instead of while and for loops as much as possible

9, use single quotation mark instead of double quotation mark reference string

10, the use of i+=1 instead of i=i+1, in line with C + + habits, efficiency is relatively high

11, for the global variable, use up should unset () off

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