我一直在研究一些示例php代码,以便在网站上创建成员区。在这些例子中,导师说你可以把<?php include 'members_area_protection.php'; ?>
放在页面的开头,然后执行其他成员区域的内容。我试图通过编写一个php文件来测试这一理论:
<?php
$name = 'Stack Overflow';
echo $name;
?>
然后将其包含在:中
<?php include 'namefile.php'; ?>
<html>
<head>
<title> Members-Only Page </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1
</head>
<body>
<p>Welcome, <?=$name?>! You have entered a members-only area
of the site. Don't you feel special?</p>
</body>
</html>
但是,当我运行php时,include文件会执行并回显名称。但其他事情都没有发生。有没有办法把它转移到文件的其余部分?从我的例子来看,它看起来不像。
谢谢!(很抱歉我刚开始使用php的基本问题)
您在这一行有问题
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1
将其替换为
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
或
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
否则代码就可以了。
您的meta tag
未关闭。您缺少">
尝试:
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">