php download.php實(shí)現(xiàn)代碼 跳轉(zhuǎn)到下載文件(response.redirect)
更新時(shí)間:2009年08月26日 00:03:06 作者:
一直對(duì)php不太熟悉,今天需要類型asp的 response.redirect語(yǔ)句,但一直沒(méi)有很好的解決方法。下面是問(wèn)了朋友才知道的。
跳轉(zhuǎn)核心代碼實(shí)現(xiàn)。
if (isset($link))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $link");
exit;
}
下面是國(guó)外的一篇文章說(shuō)明。
Hey Chris:
On Wed, Jan 26, 2005 at 12:28:19PM -0500, csnyder wrote:
>
> <?php
> // process form
> ...
> // redirect to results page
> header( 'HTTP/1.1 303 See Other' );
> header( 'Location: result.html' );
> exit( 'Form submitted, <a href="result.html">continue</a>.' );
> ?>
Good point. But some feedback here. The optimail syntax is:
<?php
// process form
// ...
// redirect to results page
header('Status: 303 See Other' );
header('Location: http://www.fzitv.net/result.html');
?>
Here's why...
Using "Status:" in the header is better because the resulting headers from
Apache are more correct:
HTTP/1.1 303 See Other
instead of
HTTP/1.1 303
Additionally, one doesn't really know which version of HTTP is being used,
so why potentially cause problems by trying to guess.
The specs say location headers must have a complete URI in them, not just
the path.
Lastly, you don't want any output after the location header.
Later,
--Dan
復(fù)制代碼 代碼如下:
if (isset($link))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $link");
exit;
}
下面是國(guó)外的一篇文章說(shuō)明。
Hey Chris:
On Wed, Jan 26, 2005 at 12:28:19PM -0500, csnyder wrote:
>
> <?php
> // process form
> ...
> // redirect to results page
> header( 'HTTP/1.1 303 See Other' );
> header( 'Location: result.html' );
> exit( 'Form submitted, <a href="result.html">continue</a>.' );
> ?>
Good point. But some feedback here. The optimail syntax is:
<?php
// process form
// ...
// redirect to results page
header('Status: 303 See Other' );
header('Location: http://www.fzitv.net/result.html');
?>
Here's why...
Using "Status:" in the header is better because the resulting headers from
Apache are more correct:
HTTP/1.1 303 See Other
instead of
HTTP/1.1 303
Additionally, one doesn't really know which version of HTTP is being used,
so why potentially cause problems by trying to guess.
The specs say location headers must have a complete URI in them, not just
the path.
Lastly, you don't want any output after the location header.
Later,
--Dan
您可能感興趣的文章:
- PHP實(shí)現(xiàn)遠(yuǎn)程下載文件到本地
- php實(shí)現(xiàn)當(dāng)前頁(yè)面點(diǎn)擊下載文件的實(shí)例代碼
- php中強(qiáng)制下載文件的代碼(解決了IE下中文文件名亂碼問(wèn)題)
- php下載文件源代碼(強(qiáng)制任意文件格式下載)
- php實(shí)現(xiàn)從ftp服務(wù)器上下載文件樹(shù)到本地電腦的程序
- PHP/ThinkPHP實(shí)現(xiàn)批量打包下載文件的方法示例
- PHP 下載文件時(shí)自動(dòng)添加bom頭的方法實(shí)例
- PHP 下載文件時(shí)如何自動(dòng)添加bom頭及解釋BOM頭和去掉bom頭的方法
- php實(shí)現(xiàn)SAE上使用storage上傳與下載文件的方法
- PHP實(shí)現(xiàn)從遠(yuǎn)程下載文件的方法
- php+js實(shí)現(xiàn)的無(wú)刷新下載文件功能示例
相關(guān)文章
PHP使用 Imagick 擴(kuò)展實(shí)現(xiàn)圖片合成,圓角處理功能示例
這篇文章主要介紹了PHP使用 Imagick 擴(kuò)展實(shí)現(xiàn)圖片合成,圓角處理功能,結(jié)合具體實(shí)例形式分析了PHP使用 Imagick 擴(kuò)展的圖形處理、生成相關(guān)操作技巧,需要的朋友可以參考下2019-09-09
php實(shí)現(xiàn)概率性隨機(jī)抽獎(jiǎng)代碼
本文給大家分享的是使用php根據(jù)獎(jiǎng)品的權(quán)重來(lái)實(shí)現(xiàn)概率性隨機(jī)抽獎(jiǎng)的代碼,非常的使用,有類似需求的小伙伴,可以拿去參考下2016-01-01
php讓json_encode不自動(dòng)轉(zhuǎn)義斜杠“/”的方法
在本篇文章里小編給大家分享的是關(guān)于php讓json_encode不自動(dòng)轉(zhuǎn)義斜杠“/”的方法,需要的朋友們可以學(xué)習(xí)下。2020-04-04

