
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
Eval Function in PHP
The eval() function evaluates a string as PHP code.
Syntax
eval(code)
Parameters
code − The PHP code to be evaluated.
Return
The eval() function returns null unless a return statement is called in the code string. Then the value passed to return is returned. if there is a parse error in the code string, eval() returns false.
Example
<?php $one = "Demo"; $two = "text"; $res = 'This is $one $two!'; echo $res. "<br>"; eval("\$res = \"$res\";"); echo $res; ?>
Output
The following is the output.
This is $one $two! This is Demo text!
Advertisements