即使函数未在页面上执行,PHP也会在函数内部抛出错误

7 php interpreted-language

如果PHP是解释语言(每条线都是在到达时执行的),如果错误发生在一个从未执行过的函数中,它怎么会抛出错误?

或者可能是我没有得到解释的意思?

例如

<?php 

$number = 1;

function square(){

 $foo = 1  //missing semicolon, throws error

}
echo $number;

?>
Run Code Online (Sandbox Code Playgroud)

ale*_*lex 7

因为在PHP解释器开始之前,首先解析其语法以尝试对其进行标记.