久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

php的header和asp中的redirect比較

瀏覽:6日期:2024-02-28 13:29:55
asp中實(shí)現(xiàn)重定向是用response.redirect 函數(shù): 用法一例: response.redirect "../test.asp" php中也有類(lèi)似函數(shù):header 用法一例: header("location:../test.php"); 但是兩者是有區(qū)別的. asp的redirect函數(shù)可以在向客戶(hù)發(fā)送頭文件后起作用. 如 <html><head></head><body> <%response.redirect "../test.asp"%> </body></html> 查是php中下例代碼會(huì)報(bào)錯(cuò): <html><head></head><body> <? header("location:../test.php"); ?> </body></html> 只能這樣: <? header("location:../test.php"); ?> <html><head></head><body>...</body></html> 即header函數(shù)之前不能向客戶(hù)發(fā)送任何數(shù)據(jù). ;;;再看下面一例: asp中 <html><head></head><body> <% response.redirect "../a.asp" response.redirect "../b.asp" %> </body></html> 結(jié)果是重定向a.asp文件. php呢? <? header("location:../a.php"); header("location:../b.php"); ?> <html><head></head><body></body></html> 我們發(fā)現(xiàn)它重定向b.php. 原來(lái)在asp中執(zhí)行redirect后不會(huì)再執(zhí)行后面的代碼. 而php在執(zhí)行header后,繼續(xù)執(zhí)行下面的代碼. ;;;;在這方面上php中的header重定向不如asp中的重定向.有時(shí)我們要重定向后,不能執(zhí)行后面的代碼: 一般地我們用 if(...) header("..."); else { ... } 但是我們可以簡(jiǎn)單的用下面的方法: if(...) { header("...");break;}
標(biāo)簽: PHP
主站蜘蛛池模板: 太白县| 岳普湖县| 宜春市| 阿坝县| 万载县| 定陶县| 壤塘县| 泰兴市| 重庆市| 康平县| 平陆县| 北川| 柳江县| 巢湖市| 兴和县| 荥经县| 孟州市| 晋城| 通江县| 蓝田县| 普宁市| 辽阳县| 南岸区| 元江| 遂平县| 宁陕县| 双鸭山市| 汝州市| 娄烦县| 阜新| 河津市| 南涧| 和顺县| 五家渠市| 名山县| 额尔古纳市| 石门县| 永定县| 扬中市| 揭阳市| 大城县|