首页 > 解决方案 > 解析错误:语法错误,第 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>

标签: phphtml

解决方案


虽然您可以使用HEREDOC,但正如另一个答案已经指出的那样,它在空间方面会带来问题。我接近它的方法是使用类似以下的东西,它可以工作并且更容易阅读:

<center><br><br>
    ID: <?php echo $_POST['user_id']; ?>
    PW: <?php echo $_POST['user_pw']; ?>
</center>

除非您只是对数据如何在页面中移动有所了解,否则不建议在页面上将用户的密码反映给他们。


推荐阅读