Hello,
I'm trying to replace {include %filename.php%} with that file from the server. I can get this to work file if the file is plan html text using the function below.
$str = "This would be a paragraph of text. {include %news.php%}";
preg_replace_callback("/\{include %(.*?)\%}/", function($m) {
return file_get_contents(CORE . 'includes/' .$m[1]);
}, $str);
But if the included file contains php code for example
<? echo "Hello World"; ?>
It doesn't work, it just prints "echo hello world".
If i change return file_get_contents to include it includes the file before my string of text. Unlike how the string is originally set with the text first then include the file.
Does anyone know how to achieve this?