MySQL_PHP學習筆記_2015_0906_使用PHP模板

來源:互聯網
上載者:User

標籤:

1. 功能說明:

index.php自動作出選擇.

如果沒有傳入參數,則載入 form.html.php; 如果有傳入參數(並且有參數firstName), 則載入welcome.html.php顯示姓名.

 

本人, 還在學習的初級階段, 如果你已然入門或是牛人, 請自動略過本文, 寫這些純粹是為了加深學習印象, 不是乾貨, 見諒…

 

2. 郊果:

初始介面:

跳轉介面:

3. 目錄welcome下一共有如下三個檔案,預設載入 index.php:

index.php

form.html.php

welcome.html.php

 

4. 代碼

index.php

<?php  if (!isset($_REQUEST[‘firstName‘]))  {      include ‘form.html.php‘;  }  else  {      $firstName = $_REQUEST[‘firstName‘];      $lastName = $_REQUEST[‘lastName‘];            $output = ‘Welcome to our website, ‘              .htmlspecialchars($firstName, ENT_QUOTES, ‘UTF-8‘)              .‘ ‘              .htmlspecialchars($lastName, ENT_QUOTES, ‘UTF-8‘)              .‘!‘;      include ‘welcome.html.php‘;  }

form.html.php

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Input Name</title></head><body>  <form action="" method="post">    <div>      <label for="firstName">First Name:        <input type="text" name="firstName" id="firstName">              </label>    </div>    <div>      <label for="lastName">Last Name:        <input type="text" name="lastName" id="lastName">      </label>    </div>    <div>      <input type="submit" value="GO">    </div>  </form></body></html>

welcome.html.php

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Form example</title></head><body>  <p>    <?php echo $GLOBALS[‘output‘]; ?>  </p></body></html>

MySQL_PHP學習筆記_2015_0906_使用PHP模板

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.