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

相关文章

深入解析fsockopen与pfsockopen的区别

按手册上说,这两个函数的唯一区别是,pfsockopen是持续连接,而fsockopen不是. 我写了个代码了一下: 复制代码 代码如下:<?php $data="1,0,721,...

php将一维数组转换为每3个连续值组成的二维数组

本文实例讲述了php实现将一维数组转换为每3个连续值组成的二维数组。分享给大家供大家参考,具体如下: <?php $aaa = array('aa','bb','cc'...

PHP获取redis里不存在的6位随机数应用示例【设置24小时过时】

本文实例讲述了PHP获取redis里不存在的6位随机数的方法。分享给大家供大家参考,具体如下: PHP获取6位数随机数 PHP str_shuffle() 函数 str_shuffle(...

基于HBase Thrift接口的一些使用问题及相关注意事项的详解

HBase对于非Java语言提供了Thrift接口支持,这里结合对HBase Thrift接口(HBase版本为0.92.1)的使用经验,总结其中遇到的一些问题及其相关注意事项。1. 字...

PHP5.3与5.5废弃与过期函数整理汇总

很多PHP程序员都知道,从PHP5.3开始加入了一个新的报错级别DEPRECATED,即将废弃/过期。下面我们来一个个版本梳理一下。 在php5.3被放弃的函数有: call_us...