PHP Development Work Experience

Source: Internet
Author: User

First, the basic knowledge of PHP itself, functions, constants, and so on, as far as possible with the built-in method to solve the problem (because the personal writing often does not have a built-in method of high-performance);

Second, the code as little as possible to implement the function (because the PHP implementation is actually, our code first processed into the underlying language for machine execution, if the code is many, the content of the conversion more natural time-consuming);

Third, the optimization can be carried out through the pressure test AB test their own code, and the code optimization, again pressure measurement efficiency;


Four, less with the @ symbol;

Use Unset () function to write off the variables.

Six, less use regular expression, double-edged sword;

Seven, avoid cycle for loop condition;

Eight, the key value of the array, be sure to use the quoted string as the key value, why do you do this?

When $arr = Array ("key" = "hehe"); $arr ["Key"] is correct, efficiency-enhancing

$arr [key] is not a good way to do this without quotes, because when PHP executes, it finds that key has no quotation marks.

At this point, he will go to check if key is a constant, if the error mechanism to open errors will prompt notice

The constant is not found for key. If you add quotation marks, PHP will go directly into the $arr array to find the key value for key,

relative efficiency is efficient.

Ix. external factors that affect PHP performance are:


The revelation of this point is that when a website is slow, it may not be the performance of PHP itself is slow, may be a network problem, may be a hardware problem, etc., as an architect to troubleshoot the problem can not stay in the program optimization!

Ten, read the memory content is less efficient than reading the database content, so that large traffic speed-up site often with Memcache, Redis and other distributed cache cache data to memory, and then first and memory to read the data;


Xi. through Xhporf (test PHP performance analysis tools from Facebook), you can test the process of visiting the website, and can be quickly found through the area of the flowchart marked red, time-consuming method, to optimize the method;


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

PHP Development Work Experience

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.