Eval() function

Eval() function

Eval () is used to evaluate the input string as PHP. It is like using the Echo() function in the sense that it outputs everything, except instead of outputting it as text, it outputs it as PHP code to be executed. One use of this is to store code in a database to execute later.

Example :

<?php

$name1 = ‘User1′;

$name2 = ‘User2′;

$a = ‘Welcome $name1,$name2′;

print $a . “<br>”;

eval(”\$a = \”$a\”;”);

print $a . “<br>”;

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.