php的header和asp中的redirect比較
想要學習PHP,那麼就應該要了解清楚header和asp中的redirect比較,下面是小編爲大家蒐集整理出來的有關於php的header和asp中的redirect比較,希望可以幫助到大家!
asp中實現重定向是用rect 函數:
用法一例:
rect "../"
php中也有類似函數:header
用法一例:
header("location:../");
但是兩者是有區別的.
asp的redirect函數可以在向客戶發送頭文件後起作用.
如
<%rect>
查是php中下例代碼會報錯:
<?
header("location:../");
?>
只能這樣:
<?
header("location:../");
?>
...
即header函數之前不能向客戶發送任何數據.
再看下面一例:
asp中
<%
rect "../"
rect "../"
%>
結果是重定向文件.
php呢?
<?
header("location:../");
header("location:../");
?>
我們發現它重定向.
原來在asp中執行redirect後不會再執行後面的代碼.
而php在執行header後,繼續執行下面的代碼.
在這方面上php中的header重定向不如asp中的`重定向.有時我們要重定向後,不能執行後面的代碼:
一般地我們用
if(...)
header("...");
else
{
...
}
但是我們可以簡單的用下面的方法:
if(...)
{ header("...");break;}
相關文章
-
The relationship between theory and practice大學英語作文
We all know that books are a source of there are those who think what the book contains must be is stupid to follow the books without any the old saying goes,to believe everything in books is worse -
php字符串替換函數str-replace速度比preg-replace快
在選擇函數的時候,我們都會優先選擇執行速度快的函數,下面是小編整理的php字符串替換函數str_replace與preg_replace的比較,希望對大家有用,更多消息請關注應屆畢業生網。php裏字符串替換的函數,有str_replace()、str_irep -
php中set-error-handler的用法
當細細地品讀完一本名著後,大家一定都收穫不少,不能光會讀哦,寫一篇讀後感吧。到底應如何寫讀後感呢?以下是小編爲大家整理的《奇蹟男孩》讀後感,歡迎閱讀與收藏。一開始,我對這本書並沒有很大興趣,只是想隨便看看而已。可是 -
The Best Thing That Could Ever Happen少兒雙語閱讀
Unit 3 The Best Thing That Could Ever Happen單元 3 最棒的事Three old men were sitting around and talking.三個老頭坐在一起聊天。The 80-year-old remarked, "The best thing that could happen to me would j -
A Letter to the Editor of a Newspaper英語四級作文
隨着現代社會的發展,人們的生活節奏在日日的姜塊,所以許多的情況下,人們都在不停的熬夜工作,還有人爲了感受夜晚下的都市,所以經常性的去過夜生活,長久以來買這些對於人的身體免疫力都是非常不好的。那麼除了這些,我們的生活 -
php的set-error-handler用法總結
導語:爲了方便大家php語言的學習與使用,下面是小編給大家提供的php的set_error_handler用法總結,大家可以參考閱讀,更多詳情請關注應屆畢業生考試網。set_error_handler() 函數設置用戶自定義的錯誤處理函數。該函數用於 -
英語作文Perfect Dream Harry Potter
Do you know Harry Potter? If you dont, then you are out of date. Many people love Harry Potter, whether children or adults. I love Harry Potter, too. Last week, I went to Nantong to see the movie Harr -
Perfect Dream Harry Potter英語作文
2022年幼兒園老師年終考覈個人總結 篇1隨着新年的鐘聲即將敲響,學期結束工作也即將結束。一個學期以來,我盡心盡責,投入於工作中,在工作中不斷實踐、總結、更新,力求做到。孩子們在各方面的能力都不同程度地提高了,同時我和 -
Efforts Urged to Improve Womens Reproductive Health英語閱讀
Efforts Urged to Improve Women's Reproductive HealthParliamentarians from over 100 countries are being urged to take action in improving women's reproductive health ahead of the 2015 deadline -
Should Private Cars Be Encouraged in China高中英語作文
with the rapid development of economy in china, the number of people who own private cars is rising day after day. quite different views eist as to this e is no doubt that private cars have been playi