As I know that the PHP is interpreted language,
while it is an interpreted how does it detects the compilation errors from the whole project and if it compiles without generating an object code, what the compilation is needed for ? only for the syntax ?
As I know that the PHP is interpreted language, while it is an interpreted
Share
I believe PHP is compiled into an internal data structure, and that internal structure is what is executed. The runtime is not reading the actual program source code line-by-line as it executes. So, the “compile” stage means that the source code is being converted to this internal data structure. At that time, the syntax is also validated and syntax errors will prevent the page from executing.
Normally, PHP has to do this parse on every request. This makes PHP somewhat slow. However, you can use http://php.net/manual/en/book.apc.php to cache the parsed code, which gives you a pretty significant speedup by avoiding the need to re-parse each time.
Also, there are various implementations of PHP that actually do compile PHP sources into bytecode or native code. From the performance information I’ve seen, compiling didn’t have a big effect on speed, but it did (in the case of Facebook’s compiler) dramatically reduce RAM consumption.