ParseError

(PHP 7, PHP 8)

Giriş

ParseError sınıfı eval() çağrıldığında olduğu gibi PHP kodu çözümlenirken bir hata oluştuğunda yavrulanır.

Bilginize: ParseError PHP 7.3.0 ve sonrasında CompileError sınıfından genişletilir. Evvelce Errorsınıfından genişletilirdi.

Sınıf Sözdizimi

ParseError extends CompileError {
/* Miras alınan özellikler */
protected string $message;
protected int $code;
protected string $file;
protected int $line;
/* Miras alınan yöntemler */
final public Error::getMessage(): string
final public Error::getPrevious(): Throwable|null
final public Error::getCode(): int
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 1 note

up
1
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