How to use eval in PHP
In this article I will explain how eval function can be used in PHP.
eval() Function
This function evaluates a string as PHP code.
Syntax
Parameter |
Description |
phpcode |
Required. Specifies the PHP code to be evaluated |
Example
<html>
<body>
<?php
$string = "beautiful";
$time = "winter";
$str = 'This is a $string $time morning!';
echo $str. "<br />";
eval("\$str = \"$str\";");
echo $str;
?>
</body>
</html> |
Output

You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here