当前位置:网站首页>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
边栏推荐
- Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
- 记录一下在深度学习-一些bug处理
- Parsing XML using Dom4j
- "Baidu Cup" CTF competition in September, web:sql
- go 字符串操作
- 龙芯派2代烧写PMON和重装系统
- Huawei push service content, read notes
- redis6数据类型及操作总结
- 真正的缓存之王,Google Guava 只是弟弟
- STM32 reverse entry
猜你喜欢

zabbix 监控

Jasypt configuration file encryption | quick start | actual combat

redis6事务和锁机制

C object storage
![[深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2](/img/52/5e85743b1817de96a52e02b92fd08c.png)
[深度学习论文笔记]使用多模态MR成像分割脑肿瘤的HNF-Netv2

Win10——轻量级小工具

Redis6 transaction and locking mechanism

These 18 websites can make your page background cool

面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?

Nantong online communication group
随机推荐
【Hot100】34. Find the first and last positions of elements in a sorted array
Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care
restTemplate详解
【华南理工大学】考研初试复试资料分享
Android本地Sqlite数据库的备份和还原
个人组件 - 消息提示
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
这18个网站能让你的页面背景炫酷起来
"Baidu Cup" CTF competition in September, web:sql
Backup and restore of Android local SQLite database
Record in-depth learning - some bug handling
Wonderful express | Tencent cloud database June issue
法国学者:最优传输理论下对抗攻击可解释性探讨
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
Log4j utilization correlation
如何把大的‘tar‘存档文件分割成特定大小的多个文件
zabbix 监控
Idea remote debugging agent
Programmer growth Chapter 8: do a good job of testing
通讯录(链表实现)