开发者

Does PHP have a virtual machine like Java?

开发者 https://www.devze.com 2023-01-09 13:30 出处:网络
Does PHP 开发者_运维知识库have a virtual machine like Java?Yes. Independently from the platform PHP is running on, the scripts are compiled into the same bytecode and run by the Zend Engine.

Does PHP 开发者_运维知识库have a virtual machine like Java?


Yes.

Independently from the platform PHP is running on, the scripts are compiled into the same bytecode and run by the Zend Engine.

The difference from Java is that this compiled code is usually not stored into separate files and the scripts are re-compiled on each execution (however, see opcode caches).


Another important difference between the Zend Engine and a typical JVM is in the way they execute bytecodes:

  • The Zend Engine executes (interprets) the compiled bytecodes directly. (At least that's what I think happens. I wasn't able to confirm this from the Zend online documentation!)
  • A JVM will normally use a JIT compiler to compile bytecodes to native instructions, and then execute the native instructions.

Actually, JVM behaviour is more complicated than this. JVMs don't always compile to native code, and when they do, they typically delay JIT compilation until they figure it is worth doing. Prior to that, they execute the bytecodes directly.


Yes, but only recently it is quite like the JVM for Java. It was invented by facebook and announced at the OSCON conference the other week (July 2013).

A news report on the new PHP VM can be read here, and the code and more info can be found on github.

0

精彩评论

暂无评论...
验证码 换一张
取 消