我想有条件地输出HTML来生成一个页面,那么在PHP 4+中回显多行HTML片段的最简单方法是什么?我需要使用像Smarty这样的模板框架吗?
echo '<html>', "\n"; // I'm sure there's a better way!
echo '<head>', "\n";
echo '</head>', "\n";
echo '<body>', "\n";
echo '</body>', "\n";
echo '</html>', "\n";
Run Code Online (Sandbox Code Playgroud) 在性能方面,什么会更好.使用PHP来回显所有的HTML输出,这样我就可以使用各种工作代码和变量,或者在整个文档中定期将HTML转义为php.
我知道可能存在一些可读性问题,但我并不担心.
谢谢大家!
例1
echo '<html>',
'<body>',
'The content of the ',$container,' element is displayed in your ', $other_container,
'</body>',
'</html>';
Run Code Online (Sandbox Code Playgroud)
要么
<html>
<body>
The content of the <?php echo $container; ?> element is displayed in your <?php echo $other_container; ?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 在发布之前我经历了这个:
仍然无法使其发挥作用.
我试图回应这个:
<div>
<h3><a href="#">First</a></h3>
<div>Lorem ipsum dolor sit amet.</div>
</div>
<div>
Run Code Online (Sandbox Code Playgroud)
但我还是找不到让标签""和"消失"的方法,我该怎么做?