用法一例:
response.redirect "../test.asp"
php中也有類似函數:header
用法一例:
header("location:../test.php");
但是兩者是有區別的.
asp的redirect函數可以 " /> 天堂8中文在线,国产精品27p,81精品国产乱码久久久久久

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php的header和asp中的redirect比較

ASP中實現重定向是用response.redirect 函數:
用法一例:
response.redirect "../test.ASP"
php中也有類似函數:header
用法一例:
header("location:../test.php");
但是兩者是有區別的.
ASP的redirect函數可以在向客戶發送頭文件后起作用.

<html><head></head><body>
<%response.redirect "../test.ASP"%>
</body></html>
查是php中下例代碼會報錯:
<html><head></head><body>
<?
header("location:../test.php");
?>
</body></html>
只能這樣:
<?
header("location:../test.php");
?>
<html><head></head><body>...</body></html>
即header函數之前不能向客戶發送任何數據.

   再看下面一例:
ASP
<html><head></head><body>
<%
response.redirect "../a.ASP"
response.redirect "../b.ASP"
%>
</body></html>
結果是重定向a.ASP文件.
php呢?
<?
header("location:../a.php");
header("location:../b.php");
?>
<html><head></head><body></body></html>
我們發現它重定向b.php.
原來在ASP中執行redirect后不會再執行后面的代碼.
php在執行header后,繼續執行下面的代碼.
    在這方面上php中的header重定向不如ASP中的重定向.有時我們要重定向后,不能執行后面的代碼:
一般地我們用
if(...)
header("...");
else
{
...
}
但是我們可以簡單的用下面的方法:
if(...)
{ header("...");break;}

php技術php的header和asp中的redirect比較,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 彭州市| 固始县| 涪陵区| 万源市| 金阳县| 丁青县| 崇左市| 小金县| 汕尾市| 北安市| 原平市| 保靖县| 通州区| 漳州市| 长丰县| 金塔县| 邛崃市| 彭阳县| 宁德市| 武夷山市| 昌宁县| 同心县| 剑川县| 贵州省| 芒康县| 秭归县| 广东省| 泽州县| 栾城县| 凤翔县| 方正县| 托里县| 镇安县| 象山县| 陆河县| 赤水市| 洛扎县| 大邑县| 新津县| 当涂县| 商河县|