Why PHP preg_replace {include ‘date.php’} does not return php? How to solve it without eval?
header('Content-Type:text/plain');
$str = "Today is {include 'date.php'}.";
echo preg_replace("/\{include '(.*)\'}/e", 'file_get_contents("$1")', $str);
date.php content:
<?php echo date('jS \of F'); ?>, 2011
Result: Today is <?php echo date('jS \of F'); ?>, 2011.
Expected result: Today is 13th of July.
Here is the solution without
\eeval:hello.php
date.php
result:
Hello! Today is 21st of July.