我的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