PHP eval function

The eval function takes a string and evaluates it is if it were PHP code:

eval("$my_var = "a site");
echo $my_var;

This code will output “a site”. The $my_var variable had not existed until the eval function was called. The return value from eval is always set to null unless the code in the evaluation part returns a value, in which case the return value is passed back as the eval return value.

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.