PHP中的if-else函数不起作用

时间:2018-07-11 05:24:45

标签: php html css

<?php
if ($_SESSION['leveluser']=='user'{?>
<div id="header">
    <div id="menu">
      <ul>
        <li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>
        <?php include "menu.php"; ?>
        <li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>
      </ul>
        <p>&nbsp;</p>
    </div>

  <div id="content">
        <?php include "content.php"; ?>
  </div>
<?php}elseif ($_SESSION['leveluser']=='admin'){?>
<div id="header">
    <div id="menu">
      <ul>
        <li><a href=?rajaampat=info><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Home</a></li>
        <?php include "menu2.php"; ?>
        <li><a href=logout.php><img src="icon/globe.ico" border="0px" width="12px" height="13px" > Logout</a></li>
      </ul>
        <p>&nbsp;</p>
    </div>

  <div id="content">
        <?php include "content2.php"; ?>
  </div>';
<?php}else {?>
    <p><b>MAAF ANDA HARUS LOG IN do e</b></p>";
<?php}?> 

我一直收到此错误: 解析错误:语法错误,在第98行的C:\ xampp \ htdocs \ WEB RAJA AMPAT \ homedir \ public_html \ myadmin \ administrator \ media.php中出现意外的'?>'

提前致谢

edit:无法在“ PHP解析/语法错误”中找到我的答案;如何解决这些错误? “

2 个答案:

答案 0 :(得分:1)

在您的代码中,检查if条件,您尚未关闭括号。将您的if条件替换为以下内容:

请更改

if($_SESSION['leveluser']=='user'{?>

if($_SESSION['leveluser']=='user'){ ?>

答案 1 :(得分:-1)

var1 = "Sentence"
var2 = "Sentence! Another sentence."