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中intval()等int转换时的意外异常情况

先看看下面的网上的一个测试代码:复制代码 代码如下:<?php$a = 9.45*100;var_dump($a);var_dump(intval($a));$a = 945*1....

Lumen timezone 时区设置方法(慢了8个小时)

根据 Laravel 4.x 和 5.0 的经验, 只需要到 config/app.php 中设置下 ‘timezone' 参数为 ‘PRC' 就好了, 找到 Lumen 的 confi...

7个鲜为人知却非常实用的PHP函数

概述 PHP有着众多的内置函数,其中大多数函数都被开发者广发使用。但也有一些同样有用却被遗忘在角落,本文将介绍7个鲜为人知功能却非常酷的函数。 highlight_string() 当需...

php使用simple_html_dom解析HTML示例

本文实例讲述了php使用simple_html_dom解析HTML的方法。分享给大家供大家参考,具体如下: 今天写了两个爬虫, 一个使用Python, 一个使用PHP, 说实在, 两个实...

php中动态变量用法实例

本文实例讲述了php中动态变量用法。分享给大家供大家参考。具体分析如下: 定义的固定变量: $my_pic_1=$row["pic_1"]; $my_pic_2=$row["pic_...