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!