如何在PHP中回显...
的index.php
$themeData = array();
$themeData['test_in_other_page'] = 'work';
mypage.php
{{TEST_IN_OTHER_PAGE}}
答案 0 :(得分:0)
这样的事情:
1:获取mypage.php的内容
$fileStr = file_get_contents('<path>/mypage.php');
2:替换项目
foreach ($themeData as $name => $content)
{
$fileStr = str_replace('{{'.$name.'}}',$content,$fileStr);
}
3:回应:
echo $fileStr;
这一切都在我理解你的问题的假设下。但模板引擎会更加灵活。