dspx15491 2019-07-14 16:22
浏览 183

使用'use'或'include'实际上是否真的将PHP文件加载到内存中? [重复]

When I use use Class\Whatever or include 'Class/Whatever' (or require etc) at the top of a file before the file's Class is declared, does that file load the included file into memory at the time, or is it only loaded in and parsed when it needs to be (lazy-loading)?

I'm not finding any resource that mentions how this behaves or if it's optimized; I'd rather call the use or include when they're needed (inside the class when I want to instantiate the included class' object), but if the minimum necessary is already being done with this, then I'll keep them at the top of the file.

Tried moving the calls around but I'm not seeing any way to tell when they actually load or are compiled and parsed.

require 'baseClasses/Controller.php';
require 'vendor/autoload.php'; // Autoload.php is generated by Composer

use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;

Expected results are for the PHP engine to simply mark a use/include for loading and parsing when a line of code actually tries to do something with it. I can't tell what the actual results are other than my code just works, but I don't want unnecessary resources loading and parsing when they're not actually being used.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序