Executing statments in a string

by raja 2009-10-01 10:23:47

To execute php code in a string,one can use eval() function.

For example,


<?php
$str = "\$x=5*log(10);";
eval($str);
echo $x;
?>


Here the $x will have the result of the expression 5*log(10).

Tagged in:

1186
like
0
dislike
0
mail
flag

You must LOGIN to add comments