2014-11-04 31 views
-1

有關工作的控制流如果頁面有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); 
    ?> 

都被執行轉儲

細節和渲染功能是..

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> 

footer.php

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

    </div> 

</body> 

回答

0

如果答案是 「有兩套HTML標籤的」 你是問錯了問題。無論顯示哪一個(它也可能因瀏覽器而異)。

+0

沒有答案是沒有兩組html標籤我只是問根據哪個規則來決定哪個標籤處理,如果代碼有這些類型的2個html標籤 – ASEN 2014-11-04 21:46:01