最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php的header和asp中的redirect比較

 更新時(shí)間:2006年10月09日 00:00:00   作者:  
asp中實(shí)現(xiàn)重定向是用response.redirect 函數(shù):
用法一例:
response.redirect "../test.asp"
php中也有類似函數(shù):header
用法一例:
header("location:../test.php");
但是兩者是有區(qū)別的.
asp的redirect函數(shù)可以在向客戶發(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ù)之前不能向客戶發(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.
原來在asp中執(zhí)行redirect后不會(huì)再執(zhí)行后面的代碼.
而php在執(zhí)行header后,繼續(xù)執(zhí)行下面的代碼.
    在這方面上php中的header重定向不如asp中的重定向.有時(shí)我們要重定向后,不能執(zhí)行后面的代碼:
一般地我們用
if(...)
header("...");
else
{
...
}
但是我們可以簡單的用下面的方法:
if(...)
{ header("...");break;}

相關(guān)文章

最新評(píng)論

吴江市| 离岛区| 辽中县| 平远县| 富顺县| 县级市| 南江县| 西昌市| 内江市| 红安县| 增城市| 深泽县| 农安县| 克拉玛依市| 庆元县| 昌平区| 大安市| 刚察县| 尼玛县| 龙游县| 绥中县| 福贡县| 大余县| 呼玛县| 武强县| 九寨沟县| 五莲县| 博客| 南溪县| 长春市| 通城县| 凤翔县| 清徐县| 梁山县| 札达县| 玉田县| 金堂县| 陇川县| 凤山市| 调兵山市| 当阳市|