how to echo in PHP like this...
index.php
$themeData = array();
$themeData['test_in_other_page'] = 'work';
mypage.php
{{TEST_IN_OTHER_PAGE}}
Something like this:
1: get the content of mypage.php
$fileStr = file_get_contents('<path>/mypage.php');
2: replace items
foreach ($themeData as $name => $content)
{
$fileStr = str_replace('{{'.$name.'}}',$content,$fileStr);
}
3: echo that:
echo $fileStr;
This all under the assumption I understand your question. But a templating engine would be far more flexible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.