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

yipeiwu_com5年前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中全局变量global的使用演示代码

我来给处入行的人讲解一下全局变量global的使用,”全局变量“,这个名词中的全局两个字已经告诉我们这个变量在各个地方都能用,先看一个实例: 复制代码 代码如下: <?php $a...

遭遇php的in_array低性能问题

遭遇php的in_array低性能问题

PHP的性能一直在提高。然而,若是用的不恰当,或是一个不留神,还是可能会踩到PHP内部实现方面的坑的。我在前几天的一个性能问题上就碰到了。 事情是这样子的,一位同事反馈我们的一个接口每次...

ThinkPHP开发框架函数详解:C方法

C方法是ThinkPHP用于设置、获取,以及保存配置参数的方法,使用频率较高。 了解C方法需要首先了解下ThinkPHP的配置,因为C方法的所有操作都是围绕配置相关的。ThinkPHP的...

JoshChen_web格式编码UTF8-无BOM的小细节分析

JoshChen_web格式编码UTF8-无BOM的小细节分析

但是在开发的过程中,发现一个小细节的问题,必须要打开F12才能看到的,原来,在head头部里面的所有引用的东西以及title等等,全部都跑到body里面去了,苦思冥想,百度、google...

PHP判断两个给定日期是否在同一周的方法

本文实例讲述了PHP判断两个给定日期是否在同一周的方法。分享给大家供大家参考,具体如下: /** * 判断两日期是不是同一周 * 星期是按周日到周六 */ function getS...