- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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!
- Related Articles
- eval() function in JavaScript
- What is the use of JavaScript eval function?
- Why is using the JavaScript eval() function a bad idea?
- Python eval()
- eval method in Python?
- Evaluate the sum of rows using the eval() function – Python Pandas
- What is the difference between void, eval, and the Function constructor in JavaScript?
- Explain JavaScript eval() function what are the rules to be followed while using it.
- file_exists() function in PHP
- basename( ) function in PHP
- chgrp()function in PHP
- chmod() function in PHP
- chown() function in PHP
- clearstatcache() function in PHP
- copy() function in PHP

Advertisements