当前位置:网站首页>How to improve the efficiency of PHP programming?
How to improve the efficiency of PHP programming?
2022-04-22 20:01:00 【ysds20211402】
from : Micro reading https://www.weidianyuedu.com
How to improve PHP Programming efficiency ?
1.、 Replace double quotation marks with single quotation marks to contain the string , It will be faster . because PHP The variable will be collected in the string enclosed in double quotation marks , Single quotes do not , Attention : as long as echo Can do this , It is a method that can treat multiple strings as parameters “ function ”
2、echo Than print fast , And the application echo Multiple parameters of ( Translation notes : Use commas instead of periods ) Replace character concatenation , like echo$str1,$str2.
3、 In performance for Before reincarnation, the number of reincarnations must be , Don't calculate the value every cycle , application foreach replace .
4、include When filing, just apply the relative diameter , Because it prevents PHP Go to include_path The rate at which files are found in , Less time is required to analyze the control system path .
5、 If you want to know the script begins to perform ( Translation notes : That is, the server receives a request from the client ) The moment of , application $_SERVER[‘REQUEST_TIME’] Better than the time().
6、 Suppose a string exchange function , Array or character can be accepted as parameter , And the parameter length is not long , Then be able to write a replacement code , Make every parameter passed a character , Instead of just writing one line of code to accept arrays as parameters for query and exchange .
7、 Define only a partial variable without using it in a function , It also slows down the rate ( The degree is equivalent to incrementing a partial variable ).PHP Maybe check if there are global variables .
8、 The use of methods seems to be related to the number of methods defined in the class , Because of me ( Before and after the test method ) Added 10 One way , But there is no change in function .
9、 Use an empty function with one argument , The time it consumes is equivalent to fulfilling 7 to 8 Partial variable increment manipulation of times . The time consumed in a similar way is close to 15 Partial variable increment manipulation of times .
10、Apache Dissect a PHP The time of a script is longer than analyzing a static HTML Page slow 2 to 10 times . Just use static HTML page , Rarely used script .
11、 Unless the script can cache , Otherwise, I will compile it again every time . Introduce a set PHP The caching mechanism can be promoted on weekdays 25% to 100% The function of , To avoid compiling expenses .
12、 Just cache , Applicable memcached.memcached It is a high-performance memory tool cache system , Can be used to speed up static Web Applications , Increase the load on the database . Pair operation code (OPcode) The cache is very effective , So that the script doesn't have to be recompiled for every request .
版权声明
本文为[ysds20211402]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221959564859.html
边栏推荐
- envoy代理后获取客户端真实IP
- Obtain the real IP address of the client after envoy proxy
- [program source code] graduation project - second-hand trading website
- New generation agent weapon - traefik
- Why is x16 slower than X8?
- This is why deep learning is so powerful
- 隔壁的wifi,我秒破
- 传:阿里达摩院裁员30%! 内部员工:谣言! 网友:要不裁29.99%。。。
- Those broken things of the tree ~ template summary
- 怎么才能申购新股呢?申购新股安全吗?
猜你喜欢
![[basic knowledge of automated testing] basic concepts and common frameworks of automated testing](/img/88/dd4884bf12474ca1870147462c9e07.png)
[basic knowledge of automated testing] basic concepts and common frameworks of automated testing

More than 100 days, 0 basic self-study and career change software testing, from 3000 to 15K monthly salary, I compiled a super complete learning guide

From functional test to automatic test, the salary doubled. I sorted out this 3000 word super complete learning guide

In 2022, the most underestimated function of postman, the efficiency of automated interface testing, is simply invincible

See how big websites play the secret of website acceleration (CDN)

家用智能投影仪首选,走进极米H3S投影

Which brand of sports headphones is better and recommended for easy-to-use sports headphones

Why is x16 slower than X8?

DNS resource records detailed explanation & authority | recursive resolution difference (super detailed)

2022年Postman最被低估的功能,自动化接口测试效率简直无敌
随机推荐
[recent function update] seamless experience free demo!
Linux下安装Mysql 8.0 + eclipse配置详细教程
Those broken things of the tree ~ template summary
DNS resource records detailed explanation & authority | recursive resolution difference (super detailed)
Problems that must be avoided in the process of top survey technology sorting and transformation
Analysis of three traversal filtering methods of JS
为什么我建议你从事技术岗,而非文职,销售
Go realizes Luhn verification of bank card
Is it true to download the financial app of qiniu business school? Is it safe to open an account in qiniu
go语言的时间格式
The concept, function, problem and solution of closure
Is it safe to open futures account on mobile phone? Do you need the assistance of offline account manager?
【牛客刷题19】MP3光标位置
文件上传问题记录
解决金仓数据库KingbaseES无法打开锁文件的问题
2022-01-12 wechat applet debugging
2022年Postman最被低估的功能,自动化接口测试效率简直无敌
[eight part essay] thread safety
【近期功能更新】无缝体验免费 Demo!
Special analysis of China's digital technology in 2022