
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP Parse Error
Introduction
ParseError class extends CompileError class. (Earlier it used to be subclass of Error class). This type of error is thrown while a PHP code inside a string that is given to eval() function as argument.
The eval() function evaluates given string as PHP code.
Syntax
eval ( string $code ) : mixed
Parameters
Sr.No | Parameter & Description |
---|---|
1 |
code valid PHP code to be evaluated |
Code to be evaluated must not be embedded in PHP opening and closing tags and must be terminated by semicolon. Valide code retuns NULL whereas error in code throws ParseError
Following example throws ParseError and is handled by catch block
Example
<?php $a=10; try{ eval('$a=$a+;'); } catch (ParseError $e){ echo "Parse Error:" . $e->getMessage(); } ?>
Output
This will produce following result −
Parse Error:syntax error, unexpected ';'
Advertisements