PHP develops several tips for improving performance

Source: Internet
Author: User
1. Use commas to concatenate strings instead of periods

echo "AAA". " bbb

echo "AAA", "BBB";


2. Use double quotation marks when strings contain variables

3.require faster than require_once

4. Calculate the cycle length in advance

 
   


5. Use the Foreache loop instead of the while live for loop (execution speed: Foreache <> < p="">

6. File access, using file_get_contents () to read the file. PHP has four ways to read data from files: Fread (), file_get_contents (), file (), and ReadFile (). Fread (), file_get_contents (), and ReadFile () return data as a string, and file () returns the data in the file as an array. Only file_get_contents () caches files in memory for faster read and write operations, which is known as memory mapping.

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