How to get the same result without /e eval – improved security and speed performance?
function finclude($file){
return include($file);
}
$str = "Today is {include 'date.php'}.";
echo preg_replace("/\{include '(.*)\'}/e", 'finclude("$1")', $str);
date.php:
<?php return date('jS \of F'); ?>, 2011
Result: Today is 20th of July.
You can use
preg_replace_callback