如何重写此PHP成员页面脚本?

时间:2013-03-14 21:02:35

标签: php include

我有这段代码,它向登录用户显示特定内容。但是使用这个我不能在页面上包含其他php文件。无论如何都要重写这个,所以我可以使用include函数。

<?php
   if($_SESSION['id'])
      echo '<div id="center" class="column">center here</div>
            <div id="left" class="column">leftbar here</div>
            <div id="right" class="column">rightbar here</div>';
   else
      echo '<h1>Staff please, <a href="index.php">login</a> 
            before accessing this page,   no access to students.</h1>';
?>

目前我不能把它放在“这里居中”,“左栏在这里”和“右栏在这里”的地方:

`<?php include("center.php"); ?>`

我是所有这些新手,所以不要太复杂,谢谢!

1 个答案:

答案 0 :(得分:0)

如果我理解正确,应该是这样的:

<?php
       if($_SESSION['id'])
          echo '<div id="center" class="column">';
               include("center.php");
          echo'</div>
                <div id="left" class="column">';
              include("leftbar.php");
         echo'</div>
                <div id="right" class="column">';
             include("rightbar.php");
          echo '</div>';
       else
          echo '<h1>Staff please, <a href="index.php">login</a> 
                before accessing this page,   no access to students.</h1>';
?>