Home > Backend Development > PHP Tutorial > PHP parsing error

PHP parsing error

王林
Release: 2023-09-15 21:50:01
forward
753 people have browsed it

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
Copy after login

Parameters

Serial numberParameters and description
1code

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();
}
?>
Copy after login

Output

This will produce the following results −

Parse Error:syntax error, unexpected &#39;;&#39;
Copy after login

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template