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 批量替换html标签的实例代码

1.把html元素全部去掉,或者保留某几个html标签复制代码 代码如下:<?php$text = '<p>Test paragraph.</p><!...

php和js如何通过json互相传递数据相关问题探讨

当我们在结合php和javascript实现某些功能时,经常会用到json。json是js的一种数据格式,可以直接被js解析。而php无法直接读取json数据,但是php提供了json_...

php常用经典函数集锦【数组、字符串、栈、队列、排序等】

php常用经典函数集锦【数组、字符串、栈、队列、排序等】

本文实例总结了php常用经典函数。分享给大家供大家参考,具体如下: 数组函数 数组操作 range(start,end) 创建一个数组,值从start开始,一直到end结束 如果r...

PHP中的日期处理方法集锦

本文包含以下内容:  1、 得到目前的日期和时间-我们有多少种方式?  2、 改变日期显示的方式-日期和时间的显示形式  3、 ...

PHP实现数据四舍五入的方法小结【4种方法】

本文实例总结了PHP实现数据四舍五入的方法。分享给大家供大家参考,具体如下: 在PHP开发中,有时候我们会遇到将数据进行四舍五入的运算情况,本文分享了用PHP实现数据四舍五入的4种方法。...