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统一页面编码避免乱码问题

页面编码统一 MySQL数据库编码、html页面编码、PHP或html文件本身编码要全部一致。 1、MySQL数据库编码: 建立数据库时指定编码(如gbk_chinese_ci),建立...

PHP实现基数排序的方法详解

PHP实现基数排序的方法详解

本文实例讲述了PHP实现基数排序的方法。分享给大家供大家参考,具体如下: 基数排序是根据关键字中各位的值,通过对排序的N个元素进行若干趟“分配”与“收集”来实现排序的。 不妨通过一个具体...

php自定义hash函数实例

本文实例讲述了php自定义hash函数实现方法。分享给大家供大家参考。具体分析如下: 这里演示php实现的一个简单hash算法,可以用来加密,不过这个函数过于简单,不能用来解密 fu...

PHP中调用ASP.NET的WebService的代码

其中有个web method像这样的: 复制代码 代码如下: [WebMethod] public string HelloWorld() { return "Hello World";...

详解php 使用Callable Closure强制指定回调类型

详解php 使用Callable Closure强制指定回调类型 如果一个方法需要接受一个回调方法作为参数,我们可以这样写 <?php function testC...