Eval()¶
The eval() function executes a string as a PHP code.
eval() has been used originally to obtain features that PHP did not offer. Nowadays, those features are rare enough that it is recommended to find a safe alternative, before relying on it.
<?php
$name = 'v';
$value = 'vvvv';
// Set a variable with a dynamic name
eval('$'.$name.' = "'.$value.'"');
// equivalent to $$name = $value;
?>
See also Eval function in PHP, The Land where PHP uses eval()