ParseError
(PHP 7, PHP 8)
简介
ParseError 当解析 PHP 代码时发生错误时抛出,比如当 eval()被调用出错时。
注意: 从 PHP 7.3.0 开始,ParseError 继承自 CompileError。之前的版本,则继承自 Error。
类摘要
/* 继承的属性 */
/* 继承的方法 */
}
+添加备注
用户贡献的备注 2 notes
SixPigPigWikiSix ¶
2 years ago
The priority of Parse Error should be higher than that of Fatal Error,Parse Error, which has the highest priority among all PHP exceptions. See the following example:
<?php
error_reporting(E_ALL);
test()
//System output a parse error
?>
<?php
error_reporting(E_WARNING);
test()
//System output a parse error
?>
<?php
error_reporting(E_ERROR);
test()
//System output a parse error
?>
<?php
error_reporting(E_PARSE);
test()
//System output a parse error
?>
andrian dot test dot job at gmail dot com ¶
5 years ago
<?php
/*
* The function eval() evaluate his argument as an instruction PHP
* Then the argument must respect the standar of PHP codage
* In this example the semicolon are missign
*/
try{
eval("echo 'toto' echo 'tata'");
}catch(ParseError $p){
echo $p->getMessage();
}
/*
* If you run this code the result is different of the result of above code
* PHP will output the standar parse Error: syntax error, ....
*
eval("echo 'toto' echo 'tata'");
*/