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多功能图片处理类

本文实例为大家分享了多功能php图片处理类,供大家参考,具体内容如下 <?php /** * Image.class.php 图像处理类 * @author...

php中对象引用和复制实例分析

本文实例讲述了php中对象引用和复制。分享给大家供大家参考,具体如下: 引用 $tv2 = $tv1; 或者 $tv2 = &$tv1; 以上两种方式,效果是一样的。...

Linux下编译redis和phpredis的方法

本文讲述了Linux下编译redis和phpredis的方法。分享给大家供大家参考,具体如下: 1、准备工作 下载软件:本站下载地址。 操作系统:CentOS 5.5 redis 版本:...

php插入排序法实现数组排序实例

本文实例讲述了php插入排序法实现数组排序的方法。分享给大家供大家参考。具体分析如下: 插入排序法的基本思路:同样以案例来说明,还是以$arr = array(2,6,3,9),由大到小...

php 遍历数据表数据并列表横向排列的代码

复制代码 代码如下:<?php $a = array (1,2,3,4,5,6,7,8,9,10,11); $i = 0; ?> <table border=1>...