/welcome/index.php
12345678910111213141516171819202122 | <?php if (!isset( $_REQUEST [ 'fn' ])) { include 'from.html.php' ; } else { $firstname = $_REQUEST [ 'fn' ]; $lastname = $_REQUEST [ 'lastname' ]; if ( $firstname == '孙' and $lastname == '哥' ) { $aa = '欢迎登陆,我的国王!' ; } else { $aa = '欢迎登陆 ' . htmlspecialchars( $firstname ,ENT_QUOTES, 'UTF-8' ) . htmlspecialchars( $lastname ,ENT_QUOTES, 'UTF-8' ) . '!' ; } include 'welcome.html.php' ; } ?> |
笔记:
isset为php内建函数,用来判断一个特定的变量是否已经被分配了一个值,有为真,无为假。
!为非运算符,为否定。
$_REQUEST['lastname'] 为获取的数组。
htmlspecialchars 为php内建函数 将特殊的html字符转换成实体。
ENT_QUOTES php常量,告知htmlspecialchars 除了其他的特殊字符外,还要转换单引号和双引号。
UTF-8 告知php已何种字符解释传递给他的文本。
/welcome/from.html.php
12345678910 | <body> <form action= "" method= "post" > <div><label for = "firstname" >First name:<input type= "text" name= "fn" id= "fn" ></label></div> <div><label for = "lastname" >Last name:<input type= "text" name= "lastname" id= "lastname" ></label></div> <div><input type= "submit" value= "提交" /></div> </form> </body> |
action属性为空,告知浏览器,将这个表单提交给接受该表单的同一个URL。
/welcome/welcome.html.php
12345 | <body> <?php echo $aa ; ?> </body> |
點擊查看更多內(nèi)容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦