ParseError

(PHP 7, PHP 8)

Introducere

ParseError is thrown when an error occurs while parsing PHP code, such as when eval() is called.

Notă: ParseError extends CompileError as of PHP 7.3.0. Formerly, it extended Error.

Sinopsisul clasei

ParseError extends CompileError {
/* Proprietăți moștenite */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Metode moștenite */
final public Error::getMessage ( ) : string
final public Error::getPrevious ( ) : Throwable
final public Error::getCode ( ) : mixed
final public Error::getFile ( ) : string
final public Error::getLine ( ) : int
final public Error::getTrace ( ) : array
final public Error::getTraceAsString ( ) : string
public Error::__toString ( ) : string
final private Error::__clone ( ) : void
}
add a note add a note

User Contributed Notes 2 notes

up
0
SixPigPigWikiSix
1 year 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
?>
up
-3
andrian dot test dot job at gmail dot com
4 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'");

*/
To Top