Php需要多个页面的模板
嗨,目前我有一个页面,看起来像:Php需要多个页面的模板,php,templates,include,require,Php,Templates,Include,Require,嗨,目前我有一个页面,看起来像: <html> <body> <?php include blahblah;?> <div> <?php include blahblah;?> </div> <p> Wordswordswords </p> <?php include blahblah;?> </body> </html> 词汇 在我的网站
<html>
<body>
<?php include blahblah;?>
<div>
<?php include blahblah;?>
</div>
<p>
Wordswordswords
</p>
<?php include blahblah;?>
</body>
</html>
词汇
在我的网站上,这是一个标准,以后要改变网站的格式是相当困难的。我想知道是否可以在文档开头设置php变量,然后继续要求模板,例如:
<?php
$words = 'words words words';
$blahdi = 'more words words';
require template;
?>
我知道这会起作用,但这是好的“编码礼仪”还是有任何缺点?我只能告诉你,第二种方法通常更好。尝试学习twig或smarty templete引擎。