如果页面有2个html标记,则工作控制流



如果页面有2个html标签,关于工作控制流

<html>
 .....
  </html>
 <html>
  .....
 </html>

其将同时执行或仅执行第一个。。。。我正在做一个cs50项目,当我打电话给时

   <?php
    dump($_SERVER);
    render("login_form.php", ["title" => "Log In"]);
    ?>

只有转储被执行,而当

  <?php
    render("login_form.php", ["title" => "Log In"]);
    dump($_SERVER);
   ?>

两者都执行

dump和render函数的详细信息如下。。

 function render($template, $values = [])
{
    // if template exists, render it
    if (file_exists("../templates/$template"))
    {
        // extract variables into local scope
        extract($values);
        // render header
        require("../templates/header.php");
        // render template
        require("../templates/$template");
        // render footer
        require("../templates/footer.php");
    }
    // else err
    else
    {
        trigger_error("Invalid template: $template", E_USER_ERROR);
    }
}

功能转储

 function dump($variable)
{
    require("../templates/dump.php");
    exit;
}

模板文件是dump.php

   <!DOCTYPE html>
 <html>
<head>
    <title>dump</title>
</head>

类似的是header.php

  <!DOCTYPE html>

<head>
    <link href="/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/css/bootstrap-theme.min.css" rel="stylesheet"/>
    <link href="/css/styles.css" rel="stylesheet"/>
    <?php if (isset($title)): ?>
        <title>Mobi3: <?= htmlspecialchars($title) ?></title>
    <?php else: ?>
        <title>Mobi3</title>
    <?php endif ?>
    <script src="/js/jquery-1.10.2.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/scripts.js"></script>
</head>
<body>
    <div class="container">
        <div id="top">
            <a href="/"><img alt="C$50 Finance" src="/img/logo.gif"/></a>
        </div>
        <div id="middle">
<body>
    <pre><?php print_r($variable); ?></pre>
</body>

页脚.php

        <div id="bottom">
            Copyright &#169; M3shop
        </div>
    </div>
</body>

如果答案是"有两组html标签",那么你问错了问题。无论显示哪一个(也可能因浏览器而异)。

最新更新