PHP eval() Function
                                            


• The eval() function evaluates a string as PHP code. 
• The string must be valid PHP code and must end with semicolon. 
• Note: A return statement will terminate the evaluation of the string immediately. 
• Tip: This function can be useful for storing PHP code in a database. 

Syntax 

eval(phpcode)

• Where phpcode is required and it specifies the PHP code to be evaluated

Example 

<?php 
$string = "beautiful"; 
$time = "winter"; 
$str = 'This is a $string $time morning!'; 
echo $str. "<br>"; 
eval("\$str = \"$str\";"); 
echo $str; 
?> 

Output :-

This is a $string $time morning! 
This is a beautiful winter morning! 

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post