PHP parsing error

王林
王林forward
2023-09-15 21:49:02675browse

PHP parsing error

Introduction

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.

Syntax

eval ( string $code ) : mixed

Parameters

Serial number Parameters and description
1 code

Valid PHP code to evaluate

##The code to be evaluated cannot be embedded in PHP opening and closing tags and must end with a semicolon. Valid code returns NULL, while code errors throw

ParseError

The following example throws a ParseError and is handled by the catch block

Example

Online Demonstration

<?php
$a=10;
try{
   eval(&#39;$a=$a+;&#39;);
}
catch (ParseError $e){
   echo "Parse Error:" . $e->getMessage();
}
?>

Output

This will produce the following results −

Parse Error:syntax error, unexpected &#39;;&#39;

The above is the detailed content of PHP parsing error. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete