我有 2 个文件:file1.php 和 file2.html。所以在 file1.php 我有:
...
//some variables like $title and $message
echo '<p><h1>' . $title . '</h1></p>' .
'<p>' . $message . '</p>';
require('file2.html');
...
我想在我的 HTML 页面的标签中使用echo
它。center
但是当我在浏览器中打开 file2.html 时会发生以下情况:
<p><h1>Title</h1></p><p>Message</p>
<!-- And so the doctype comes AFTER the PHP input. This ruins the whole code -->
<!DOCTYPE html>
<html dir="ltr" lang="en-us">
<head>
<title>Example</title>
<script type="text/javascript" src="/scripts/script.js></script>"
</head>
<body style="background-color: #FBFBFB;">
<p><a href="/" title="Home">Home</a></p>
<p><a href="/contact.html" title="Contact Us">Contact Us</a>.</p>
<p><a href="/forums/" title="Forums">Forums</a></p>
<center>
</center>
</body>
</html>