php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com6年前PHP代码库
跳转核心代码实现。
复制代码 代码如下:

if (isset($link))
                {
                    Header("HTTP/1.1 303 See Other");
                    Header("Location: $link");
                    exit;
                }



下面是国外的一篇文章说明。
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: //www.jb51.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传输数据的代码

表单复选框就是checkbox   1、checkbox的应用 复制代码 代码如下:   <input type="checkbo...

php数组函数array_walk用法示例

本文实例讲述了php数组函数array_walk的用法。分享给大家供大家参考,具体如下: $words=array("l"=>"lemon","o"=>"orange",...

PHP常用的文件操作函数经典收藏

以下是个人总结的PHP文件操作函数。当然,这只是部分,还有很多,我没有列出来。 一 、解析路径: 1 获得文件名: basename(); 给出一个包含有指向一个文件的全路径的字符串,本...

关于URL最大长度限制的相关资料查证

在开发调试支付宝接口时,突然发现支付宝接口的URL很长,远远大于之前自己印象中的255个字符。赶紧搜索查证了一番,理解如下: URL不能大于255bytes的说法确实存在,在RFC261...

php实现XML和数组的相互转化功能示例

本文实例讲述了php实现XML和数组的相互转化功能。分享给大家供大家参考,具体如下: 数组转化为xml: function arrtoxml($arr,$dom=0,$item=0)...