Home >Backend Development >PHP Tutorial >PHP parsing error
ParseError class extends the CompileError class. (Previously it used to be a subclass of the Error class). This type of error is raised when PHP code is inside a string passed as an argument to the eval() function.
eval() Function evaluates the given string into PHP code.
eval ( string $code ) : mixed
Serial number | Parameters and description |
---|---|
1 |
code Valid PHP code to evaluate |
ParseError
The following example throws a ParseError and is handled by the catch blockExample Online Demonstration<?php $a=10; try{ eval('$a=$a+;'); } catch (ParseError $e){ echo "Parse Error:" . $e->getMessage(); } ?>OutputThis will produce the following results −
Parse Error:syntax error, unexpected ';'
The above is the detailed content of PHP parsing error. For more information, please follow other related articles on the PHP Chinese website!