php - 解析错误:语法错误,第 48 行出现意外的 '<<' (T_SL)
问题描述
我有这个代码,但我得到了
解析错误:语法错误,第 48 行出现意外的 '<<' (T_SL)
我认为问题出在php代码上。但是,我不知道它是什么。有人可以解释为什么会出现这个错误,或者我的脚本缺少什么吗?
谢谢。
<!DOCTYPE html>
<html>
<head>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script>
function updatemenu() {
if (document.getElementById('responsive-menu').checked == true) {
document.getElementById('menu').style.borderBottomRightRadius = '0';
document.getElementById('menu').style.borderBottomLeftRadius = '0';
}else{
document.getElementById('menu').style.borderRadius = '9px';
}
}
</script>
</head>
<body>
<div id="content">
<center><br><br>
<?php
$uid=<<<EOD
ID : $_POST['user_id']
EOD;
$upw=<<<EOD
PW : $_POST['user_pw']
EOD;
echo $uid;
echo $upw;
?>
</center><br><br><br><br>
</div>
</body>
</html>
解决方案
虽然您可以使用HEREDOC,但正如另一个答案已经指出的那样,它在空间方面会带来问题。我接近它的方法是使用类似以下的东西,它可以工作并且更容易阅读:
<center><br><br>
ID: <?php echo $_POST['user_id']; ?>
PW: <?php echo $_POST['user_pw']; ?>
</center>
除非您只是对数据如何在页面中移动有所了解,否则不建议在页面上将用户的密码反映给他们。
推荐阅读
- java - 使用 if 找出三个数中最小的数
- java - 如何在 Drools 的决策表中使用命中策略
- node.js - 如何通过运行 npm install 解决 JSON 错误?
- reactjs - 如何忽略通过 HTTP 进行更改的客户端的 websocket 事件?
- python - 我需要在字典中保留某些键,并删除不必要的键
- dependencies - 组件“RICHTX32.OCX”或其依赖项之一未正确注册:文件丢失或无效
- html - 如何从静态隐私/法律/条件资产文档中访问全局 styles.scss?
- firebase - 是否可以查看有多少数据存在于 firebase 事件中?
- c# - 如何使用 Entity Framework Core 从数据图中分离实体?
- windows - 如何从 Windows ICMP.DLL 诊断访问被拒绝错误