Using eval() to Evaluate a PHP Script in Another PHP Script

Let’s say you have a PHP script called message.php with the following contents:

[cc lang=”php”]
Hello, $name;
[/cc]

You can evaluate this code by reading it into a variable as using the eval() function as follows:

[cc lang=”php”]
$name = “David”;
$fh = fopen(“message.php”, ‘r’);
$message = fread($fh, filesize(“message.php”));
eval(“$message = “$message”;”);
echo $message; // prints Hello, David
[/cc]