在回声中包含一次

include once inside echo

我有两个 headers,我想根据帐户类型显示它们; "a" 用于管理员类型,"b" 用于普通用户类型。 我已经有了枚举集 'a'、'b'。现在,对于连接到数据库后的 php,我有:

    <?php
    while ($row = mysql_fetch_array($sql)){
        $name = $row["name"];
        $accounttype = $row["accounttype"];
          if($accounttype == "a"){
            $header = include_once "header_a.php";
          }
          if($accounttype == "b"){
            $header = include_once "header_b.php";
        }
    }
    ?>

至于html,我有:

   <html>
   <body>

     <?php echo $accounttype; ?>

   </body>
   </html>

编辑: 好的,我让它以正确的方式工作:

   <?php
    $header ="";
    while ($row = mysql_fetch_array($sql)){
        $name = $row["name"];
        $accounttype = $row["accounttype"];
          if($accounttype == "a"){
            include_once "header_a.php";
          }else{
          include_once "header_b.php";
       }
    }
    ?>

   <html>
   <body>

     <?php echo $header; ?>

   </body>
   </html>

为什么不是这样的:

<?php
while ($row = mysql_fetch_array($sql)){
    $name = $row["name"];
    $accounttype = $row["accounttype"];
}

include_once "header_".$accounttype.".php";
?>


<html>
<body>

    <?php echo $accounttype; ?>

</body>
</html>