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

相关文章

Netbeans 8.2将支持PHP7 更精彩

Netbeans 8.2将支持PHP7 更精彩

首先,将PHP项目的PHP版本设置为PHP 7.0。 PHP 7其中一项新特性是返回类型声明,即PHP的函数和方法可以声明指定类型的返回值: PHP 7的另一项精彩的改进就是参数的...

PHP中变量引用与变量销毁机制分析

本文实例分析了PHP中变量引用与变量销毁机制。分享给大家供大家参考。具体分析如下: 变量是php中一个非常重要的类型了,我们的有数据都通过变量或常量来进行操作,下文来看看变量引用与变量销...

redis+php实现微博(三)微博列表功能详解

本文实例讲述了redis+php实现微博列表功能。分享给大家供大家参考,具体如下: 个人主页显示微博列表(自己及关注人的微博列表) /*获取最新的50微博信息列表,列出自己发布的微博...

PHP array_multisort() 函数的深入解析

一、先看最简单的情况。有两个数组:$arr1 = array(1,9,5);$arr2 = array(6,2,4);array_multisort($arr1,$arr2);print...

PHP数组传递是值传递而非引用传递概念纠正

在调用函数时通过将PHP数组作为实参赋给形参,在函数中修改,并不会影响到数组本身。 说明此过程中的传递为值传递,数组变量并非是指向此数组本身的引用,PHP数组本身以值的形式存在,同时形参...