Course Banner

Interpreted vs. Compiled

JavaScript is an interpreted language while Java is a compiled language. In general, PHP is also an interpreted language but PHP uses a blend of interpretation and compilation in order to provide the best mix of performance and flexibility to programmers.

Underneath, PHP compiles your script down to a series of instructions (called opcodes) whenever it is accessed. These instructions are then executed one by one until the script ends. PHP is not same as conventional compiled languages such as C++ where the code is compiled to native executable code then that executable is runs. On the other hand, PHP compiles its file again if required be for each request.

The main benefit of being interpreted code is that complete memory used by the script is managed by PHP, and the language automatically cleans up after every script has finished. One does not have to worry about closing database connection, freeing memory assigned to images, and so on, because PHP takes care of all these things itself.