[英]how to echo in PHP like this
how to echo in PHP like this... 如何像这样在PHP中回显...
index.php index.php
$themeData = array();
$themeData['test_in_other_page'] = 'work';
mypage.php mypage.php
{{TEST_IN_OTHER_PAGE}}
Something like this: 像这样:
1: get the content of mypage.php 1:获取mypage.php的内容
$fileStr = file_get_contents('<path>/mypage.php');
2: replace items 2:更换物品
foreach ($themeData as $name => $content)
{
$fileStr = str_replace('{{'.$name.'}}',$content,$fileStr);
}
3: echo that: 3:回声:
echo $fileStr;
This all under the assumption I understand your question. 所有这些都是在我理解您的问题的假设下进行的。 But a templating engine would be far more flexible. 但是,模板引擎将更加灵活。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.