我的index.php看起來是這樣的:PHP回聲變量從包括之前包括
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title?></title>
</head>
<body>
<p>Hi, this is my homepage. I'll include some text below.</p>
<?php
include "myfile.php";
?>
</body>
</html>
「myfile.php」 例如包括以下內容:
<?php
$title = "Hi, I'm the title tag…";
?>
<p>Here's some content on the site I included!</p>
輸出的<p>
GOTS但<title>
標籤保持空白。
如何從包含的網站獲得$title
並在<body>
標籤中顯示包含的內容?
你使用echo $標題屏幕顯示。 –
你想做什麼。 'include'用於包含文件。讓你的問題更清楚一點。 – Sasikumar
在使用'$ title'變量之前,您的文件必須包含在內。 – Sasikumar