当前位置:网站首页>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
边栏推荐
猜你喜欢

Idea设置方法注释和类注释

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

stm32逆向入门
![[public class preview]: basis and practice of video quality evaluation](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[public class preview]: basis and practice of video quality evaluation

Nantong online communication group

Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications

NFT value and white paper acquisition

这18个网站能让你的页面背景炫酷起来

Redis6 master-slave replication and clustering

FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
随机推荐
French scholars: the explicability of counter attack under optimal transmission theory
Flutter InkWell & Ink组件
MySQL - database query - sort query, paging query
Can and can FD
不知道这4种缓存模式,敢说懂缓存吗?
研究生可以不用学英语?只要考研英语或六级分数高!
Zhubo Huangyu: these spot gold investment skills are not really bad
leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
Zhubo Huangyu: it's really bad not to understand these gold frying skills
搭建一个仪式感点满的网站,并内网穿透发布到公网 2/2
那些考研后才知道的事
今年上半年,通信行业发生了哪些事?
Backup and restore of Android local SQLite database
【Hot100】34. 在排序数组中查找元素的第一个和最后一个位置
FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
Interviewer soul torture: why does the code specification require SQL statements not to have too many joins?
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
Multi person cooperation project to see how many lines of code each person has written
Summary and arrangement of JPA specifications
【云资源】云资源安全管理用什么软件好?为什么?