国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

PHP和ASP中關于轉向函數的區別

瀏覽:96日期:2024-03-02 13:07:14

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('...');b

reak;}

標簽: PHP
相關文章:
主站蜘蛛池模板: 翁牛特旗| 海口市| 浙江省| 太保市| 武川县| 高雄县| 共和县| 定兴县| 县级市| 宜兰市| 澎湖县| 台江县| 贵南县| 蓝山县| 策勒县| 常熟市| 黄梅县| 鹤山市| 炉霍县| 勐海县| 弥渡县| 时尚| 丰宁| 郧西县| 曲松县| 左权县| 洪洞县| 清水河县| 临漳县| 高碑店市| 孙吴县| 江阴市| 望城县| 安图县| 沾化县| 思茅市| 洞头县| 衡东县| 乡城县| 临湘市| 京山县|