我有PHP变量放置在一个包含的HTML文件中。执行此操作的最佳方式是什么?在PHP中包含动态HTML
//contents of file1.php
$variable1 = "text 1";
$variable2 = "text 2"
$newContent = include('file2.php');
echo $newContent;
//contents of file2.php
<p>standard HTML with PHP... <strong><?=$variable1?></strong></p>
<p><?=$variable2?></p>
这种一般方法被认为是确定的,但这里的实际代码不起作用。我是否使用file_get_contents()或include(),如何在包含文件中执行PHP以输出正确的内容?
我应该使用类似HTML>>>
请参阅编辑我的答案 – 2009-10-24 09:28:39