Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is PHP compiled or interpreted?

Tags:

php

People also ask

Is PHP an interpreter or compiler?

Basically, PHP is interpreted but PHP is compiled down to an intermediate bytecode that is then interpreted by the runtime Zend engine.

Are PHP files compiled?

PHP creates a bytecode intermediary when the file has changed and. The code stays "Precompiled" and it is only compiled again if the php script has changed and it is the first time it's being demanded before it's precompilation.

Is PHP run time or compile time?

PHP makes two passes (by default) anytime it runs a file. 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.

What does PHP interpreted do?

PHP is an interpreted language. The binary that lets you interpret PHP is compiled, but what you write is interpreted. He means the utility called php (or on windows php.exe) is compiled. @nicky It means that the program that's used to interpret PHP is compiled, but the PHP itself is interpreted.


PHP is an interpreted language. The binary that lets you interpret PHP is compiled, but what you write is interpreted.

You can see more on the Wikipedia page for Interpreted languages


Both. PHP is compiled down to an intermediate bytecode that is then interpreted by the runtime engine.

The PHP compiler's job is to parse your PHP code and convert it into a form suitable for the runtime engine. Among its tasks:

  • Ignore comments
  • Resolve variables, function names, and so forth and create the symbol table
  • Construct the abstract syntax tree of your program
  • Write the bytecode

Depending on your PHP setup, this step is typically done just once, the first time the script is called. The compiler output is cached to speed up access on subsequent uses. If the script is modified, however, the compilation step is done again.

The runtime engine walks the AST and bytecode when the script is called. The symbol table is used to store the values of variables and provide the bytecode addresses for functions.

This process of compiling to bytecode and interpreting it at runtime is typical for languages that run on some kind of virtual runtime machine including Perl, Java, Ruby, Smalltalk, and others.


A compiled code can be executed directly by the computer's CPU. That is, the executable code is specified in the CPU's native language.

The code of interpreted languages must be translated at run-time from any format to CPU machine instructions. This translation is done by an interpreter.

It would not be proper to say that a language is interpreted or compiled, because interpretation and compilation are both properties of the implementation of that particular language and not a property of the language as such. So, any language can be compiled or interpreted — it just depends on what the particular implementation that you are using does.

The most widely used PHP implementation is powered by the Zend Engine and is known simply as PHP. The Zend Engine compiles PHP source into a format that it can execute, thus the Zend engine works as an interpreter.


In generally it is interpreted, but some time can use it as compiled and it is really increases performance. Open source tool to perform this operation: hhvm.com


PHP is an interpreted language. It can be compiled to bytecode by third party-tools, though.