PHP编译时间与运行时间.了解差异 [英] PHP compile time vs run time. Understanding the difference

查看:73
本文介绍了PHP编译时间与运行时间.了解差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常听到这两个词,并且不断思考

I hear those two terms often and keep thinking

PHP的编译时间与运行时间有什么区别?

What is the difference between compile time vs run time in PHP?

我尝试阅读一些文章,但没有帮助.

I have tried reading some articles, but it didn't help.

有人知道一个简单的解释吗?它们彼此之间有何不同?

Does anyone know of a simple explanation? How are they different from each other?

推荐答案

PHP每次运行文件时都会进行两次传递(默认情况下).

PHP makes two passes (by default) anytime it runs a file.

Pass#1解析文件并构建所谓的操作(或机器)代码.这是您的计算机将实际运行的原始二进制格式,并且不可读.在其他语言(如C ++等)中,这称为编译.您可以使用 Opcache 之类的各种系统来缓存该步骤,从而节省了每次编译该代码的开销.

Pass #1 parses the file and builds what is called operational(or machine) code. This is the raw binary format your computer will actually run and it is not human readable. In other languages (like C++, etc) this is called compiling. You can cache this step using various systems like Opcache, which saves you the overhead of compiling this every time.

语法错误来自执行的这一部分.

Syntax errors come from this portion of the execution.

Pass#2执行Pass#1中的操作代码.这就是通常所说的运行时",因为您的计算机实际上正在执行指令.

Pass #2 executes the operational code from Pass #1. This is what is commonly called "run time", because your computer is actually executing the instructions.

运行时错误(例如,耗尽内存,异常终止等)来自此级别.但是,这些错误比语法错误要普遍得多.

Run-time errors (like exhausting memory, abnormal termination, etc) come from this level. These are considerably less common than syntax errors, however.

这篇关于PHP编译时间与运行时间.了解差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆