开发者

About the PHP excution, it's line-by-line or file-by-file?

开发者 https://www.devze.com 2023-02-03 12:21 出处:网络
PHP is execute line by line or just like java that it\'s compiled form byte开发者_运维百科 code to binary code file by file?The whole files is parsed before anything get executed.

PHP is execute line by line or just like java that it's compiled form byte开发者_运维百科 code to binary code file by file?


The whole files is parsed before anything get executed. After this parser, PHP runs instruction by instruction. If your first instruction is a require/include, PHP will open the file and read their instructions (layered)


PHP translates sources into opcode and after that evaluates it instruction by instruction.


It's executed instruction by instruction. But before it gets executed, the whole file is parsed. Thus a syntax error occurs before anything gets executed.


You can see PHP is not executed line-by-line, because you get syntax errors from whole file even before first line was executed (even in function which are not called at all).

If you want an example of line-by-line language, see Windows command line (it applies to unix sh files too) batch file language - you can type anything into lines which are not executed (for example because you terminate the file before the line gets parsed) and you won't get any kind of error.

0

精彩评论

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

关注公众号