PHP 8.5.0 Beta 3 available for testing

ParseError

(PHP 7, PHP 8)

ใฏใ˜ใ‚ใซ

ParseError ใฏใ€eval() ใ‚’ๅ‘ผใ‚“ใ ใจใใชใฉใฎ PHP ใ‚ณใƒผใƒ‰ใฎใƒ‘ใƒผใ‚นใซๅคฑๆ•—ใ—ใŸๅ ดๅˆใซใ‚นใƒญใƒผใ•ใ‚Œใพใ™ใ€‚

ๆณจๆ„: PHP 7.3.0 ไปฅ้™ใฏใ€ParseError ใ‚ฏใƒฉใ‚นใฏ CompileError ใ‚ฏใƒฉใ‚นใ‚’็ถ™ๆ‰ฟใ™ใ‚‹ใ‚ˆใ†ใซใชใ‚Šใพใ—ใŸใ€‚ ไปฅๅ‰ใฎใƒใƒผใ‚ธใƒงใƒณใงใฏใ€Error ใ‚’็ถ™ๆ‰ฟใ—ใฆใ„ใพใ—ใŸใ€‚

ใ‚ฏใƒฉใ‚นๆฆ‚่ฆ

class ParseError extends CompileError {
/* ็ถ™ๆ‰ฟใ—ใŸใƒ—ใƒญใƒ‘ใƒ†ใ‚ฃ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private ?Throwable $previous = null;
/* ็ถ™ๆ‰ฟใ—ใŸใƒกใ‚ฝใƒƒใƒ‰ */
public Error::__construct(string $message = "", int $code = 0, ?Throwable $previous = null)
final public Error::getMessage(): string
final public Error::getCode(): int
final public Error::getFile(): string
final public Error::getLine(): int
final public Error::getTrace(): array
private Error::__clone(): void
}
๏ผ‹add a note

User Contributed Notes 2 notes

up
0
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
?>
up
-2
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'");

*/
To Top