我有一個文件的template.php PHP代碼:如何運行的file_get_contents
<html>
<head>
<title>{title}</title>
</head>
<body>
<div id="header">
<h1>This is header</h1>
</div>
<div id="content">
<h1>This is content</h1>
<?php $this->showContent(); ?>
</div>
<div id="footer">
<p>Copyright © <?= date('Y'); ?> by My Company.</p>
</div>
</body>
</html>
,並在文件controll.php,代碼如下所示:
$file = file_get_contents('template.php');
echo $file;
但不運行php腳本$this->showContent();
。
有人可以幫我嗎?
您包含代碼文件,而不是使用'file_get_contents'的輸出 –
這非常基本。在問這個問題之前,您可能需要閱讀PHP手冊。 – Capsule
它似乎可能使用模板引擎。你知道'{title}'應該被替換嗎? – cornelb