[英]how to echo in PHP like this
如何像這樣在PHP中回顯...
index.php
$themeData = array();
$themeData['test_in_other_page'] = 'work';
mypage.php
{{TEST_IN_OTHER_PAGE}}
像這樣:
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;
所有這些都是在我理解您的問題的假設下進行的。 但是,模板引擎將更加靈活。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.