标签:
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模板
标签:
原文地址:http://www.cnblogs.com/BigBigLiang/p/4785728.html