我想创建更干净的html文档/模板,该文档使用echo命令调用html / script片段。
虽然..我不知道如何使它工作。
我要到达的文件就像
<html>
<head>
</head>
<body>
<?php
echo 'header.html';
echo 'container.html';
echo 'footer.html';
?>
Run Code Online (Sandbox Code Playgroud)
因此,通过这种方式,我可以在单个文档中编辑网站的每个部分,而不是整体编辑网站的所有部分。
<?php
$myString = 'include(portfolio.php); ';
echo $myString;
echo file_get_html('portfolio.php');
echo file_get_html('portfolio.html');
?>
Run Code Online (Sandbox Code Playgroud)
(为进行尝试,我在html和php文档(?>)中都放置了一段仅HTML编码,以尝试是否有任何区别。。)
但是..你们可能都知道:这行不通。
因此,只要您的回答很简单:
如上所示,我如何在外部文件中“回显”片段/所有内容:回显“ portfolio.html”内容。
谢谢!
ps:我认为echo是“粘贴”外部编码的最佳选择,但如果您有更好,更轻松,更多的SEO解决方案:请成为我的客人!
用途包括
<html>
<head>
</head>
<body>
<?php
include 'header.html';
include 'container.html';
include 'footer.html';
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
http://php.net/manual/zh/function.include.php