当前位置:网站首页>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
边栏推荐
- 【云资源】云资源安全管理用什么软件好?为什么?
- Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- What is a network port
- Log4j utilization correlation
- 一网打尽异步神器CompletableFuture
- Shuttle INKWELL & ink components
- Binder communication process and servicemanager creation process
- 【Hot100】33. 搜索旋转排序数组
- Android本地Sqlite数据库的备份和还原
猜你喜欢

What about data leakage? " Watson k'7 moves to eliminate security threats

今年上半年,通信行业发生了哪些事?
![[深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2](/img/52/5e85743b1817de96a52e02b92fd08c.png)
[深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2

Cloudcompare - point cloud slice

研究生可以不用学英语?只要考研英语或六级分数高!

Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications

Jenkins installation

Redis6 transaction and locking mechanism

TortoiseSVN使用情形、安装与使用

内网穿透工具 netapp
随机推荐
49. Grouping of alphabetic ectopic words: give you a string array, please combine the alphabetic ectopic words together. You can return a list of results in any order. An alphabetic ectopic word is a
Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑
Basic characteristics and isolation level of transactions
RK3566添加LED
【Hot100】33. 搜索旋转排序数组
Log4j utilization correlation
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
Clock cycle
Rocky basic command 3
[deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging
Flutter 3.0更新后如何应用到小程序开发中
The real king of caching, Google guava is just a brother
mysql获得时间
Prefix, infix, suffix expression "recommended collection"
【Hot100】33. Search rotation sort array
asp. Net read TXT file
[server data recovery] a case of RAID5 data recovery stored in a brand of server
MySQL get time
The development of speech recognition app with uni app is simple and fast.
go 字符串操作