[PHP] Execution/evaluation of code from variable

[PHP] Execution/evaluation of code from variable

In PHP we can use function eval in order to evaluate given variable (string) as PHP code:

<? 
$var = 'for ($i=0;$i<5;$i++)
{
	echo $i.\'<br>\';
}';
eval($var);
?>

output:

0
1
2
3
4

3 thoughts on “[PHP] Execution/evaluation of code from variable

Leave a Reply

Your email address will not be published.