|
Posted by Pedro Graca on 11/11/06 23:17
brett wrote:
> <?php
> $content = file_get_contents(TEMPLATEPATH . '/somefile.php');
> echo eval("$content");
echo eval('?>' . $content);
> ?>
I like to think of it as if eval() evaluates its parameter /starting/ in
PHP mode. So, if your data (from somefile.php) starts with "<?php" you
need to get out of PHP mode first, then, when eval() sees "<?php" it
will enter PHP mode and execute the rest.
<?php
unset($x);
$data = '$x = 42;';
eval($data);
echo $x, "\n";
unset($x);
$data = '<?php $x = 42; ?>';
eval('?>' . $data);
echo $x, "\n";
?>
The more balanced "eval('?>' . $data . '<?php');" gives a stupid parse
error!
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Navigation:
[Reply to this message]
|