PHP improves programming efficiency (2)-php Tutorial

Source: Internet
Author: User
PHP improves programming efficiency (2) 1. str_replace functions are faster than preg_replace functions, but strtr functions are four times more efficient than str_replace functions.

2. if a string replacement function can take an array or character as a parameter and the parameter length is not too long, you can consider writing an additional replacement code so that each parameter passing is a character, instead of writing only one line of code to accept arrays as query and replacement parameters.

3. use the select branch statement.

4. blocking error messages with @ is very inefficient and extremely inefficient.

5. open the mod_deflate module of apache to speed up web browsing.

6. the database connection should be closed when use is complete. do not use persistent connections.

7. the error message is expensive.

8. increment local variables in the method at the fastest speed. It is almost the same as calling a local variable in a function.

9. increasing a global variable is twice slower than increasing a local variable.

10. incrementing an object property (for example, $ this-> prop ++) is three times slower than incrementing a local variable.

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.