当前位置:网站首页>Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library
Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library
2022-07-05 13:42:00 【Black hearted green rose】
include() And require() The same function
The only difference :require() Whether executed or not , As long as there is a ,php It will be pre introduced before execution ,include() It is not introduced until the statement is executed
include_once() And require_once() Is to detect whether the file is imported , If it is introduced, it will not be introduced
The only difference : require_once() Unconditionally include , As the name suggests, that is, stop if there is an error after the introduction ,include_once() Then ignore and continue
On efficiency , I want to explain , Please consciously use less include_once()、 require_once()
The principle of this function : The introduction of the file -> Compare whether the current script statement contains -> Decide whether to introduce , Efficiency is conceivable , You think if you have hundreds of class libraries in the whole project , How terrible is it to compare dozens of times in one execution
Here is a solution to prevent the repeated introduction of files in personal multi class libraries :
1. In the calling script, use require();
2. Prevent reuse in class libraries class_exists(‘ Class name ’) or include(‘ Absolute path of class library ’);
explain : The file that calls the script is used once require(), Because the calling script is the general entry of the program , The introduction of public class libraries here rarely results in public class libraries not being used , Use the above statement in the class library , It can prevent the current script from repeatedly introducing the public class library , And only by judging the conditions can the introduction be executed , Pre import will not be repeated , Improve the efficiency of program execution
边栏推荐
- NFT value and white paper acquisition
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- 【云资源】云资源安全管理用什么软件好?为什么?
- 53. Maximum subarray sum: give you an integer array num, please find a continuous subarray with the maximum sum (the subarray contains at least one element) and return its maximum sum.
- 真正的缓存之王,Google Guava 只是弟弟
- Usage, installation and use of TortoiseSVN
- FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
- The real king of caching, Google guava is just a brother
- redis6主从复制及集群
- Win10 - lightweight gadget
猜你喜欢
Write API documents first or code first?
【华南理工大学】考研初试复试资料分享
“百度杯”CTF比赛 九月场,Web:SQL
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
[public class preview]: basis and practice of video quality evaluation
[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接
The development of speech recognition app with uni app is simple and fast.
Catch all asynchronous artifact completable future
ZABBIX monitoring
[server data recovery] a case of RAID5 data recovery stored in a brand of server
随机推荐
[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
"Baidu Cup" CTF competition in September, web:upload
[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
私有地址有那些
FPGA learning notes: vivado 2019.1 add IP MicroBlaze
Log4j utilization correlation
SAE international strategic investment geometry partner
FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
53. Maximum subarray sum: give you an integer array num, please find a continuous subarray with the maximum sum (the subarray contains at least one element) and return its maximum sum.
Summit review | baowanda - an integrated data security protection system driven by compliance and security
Idea remote debugging agent
These 18 websites can make your page background cool
ELFK部署
Jenkins installation
Usage, installation and use of TortoiseSVN
asp.net 读取txt文件
Catch all asynchronous artifact completable future
Resttemplate details
[daily question] 1200 Minimum absolute difference