Home > Backend Development > PHP Tutorial > PHP performance efficiency optimization_PHP tutorial

PHP performance efficiency optimization_PHP tutorial

WBOY
Release: 2016-07-13 17:08:52
Original
795 people have browsed it

php performance efficiency optimization
Recently, I am self-studying and writing PHP programs in the company. Since the company has high requirements for the running efficiency of the program, and I am a novice, it is important to pay attention to the efficiency of the program from the beginning. Here I will summarize the efficiency of the PHP program based on some information on the Internet. Some strategies for optimization:

1. When file_get_contents can be used instead of file, fopen, feof, fgets and other series of methods, try to use file_get_contents because it is much more efficient! But please pay attention to the PHP version problem of file_get_contents when opening a URL file

2. Conduct file operations as little as possible, although PHP’s file operations are not inefficient;

3. Optimize the Select SQL statement and perform as few Insert and Update operations as possible (I was criticized for updating);

4. Use PHP internal functions as much as possible (but in order to find a function that does not exist in PHP, I wasted time that could have been written a custom function, a matter of experience!);

5. Do not declare variables inside the loop, especially large variables: objects (this seems to be not just a problem in PHP, right?);

6. Try not to loop nested assignments in multi-dimensional arrays;

7. Do not use regular expressions when you can use PHP’s internal string manipulation functions;

8. foreach is more efficient, try to use foreach instead of while and for loop;

9. Use single quotes instead of double quotes to quote strings;

10. "Use i+=1 instead of i=i+1. It conforms to the habits of c/c++ and is more efficient";

11. Global variables should be unset()ed when used up

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629800.htmlTechArticlephp performance efficiency optimization. Recently, I am self-study and writing PHP programs in the company, because the company has high requirements for the operating efficiency of the program. , and I am a novice, so I pay attention to the efficiency of the program from the beginning...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template