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根据某字段对多维数组进行排序的方法

本文实例讲述了php根据某字段对多维数组进行排序的方法。分享给大家供大家参考。具体分析如下: 根据某字段对多维数组进行排序,在看到array_multisort方法的作用时突然想到,可以...

php中array_column函数简单实现方法

本文实例讲述了php中array_column函数简单实现方法。分享给大家供大家参考,具体如下: php中的array_column()可返回输入数组中某个单一列的值。 示例: &l...

php创建和删除目录函数介绍和递归删除目录函数分享

mkdir() — 新建目录 复制代码 代码如下: – 语法:bool mkdir (string pathname [,int mode]) – 尝试新建一个由 pathname 指定...

PHP进制转换实例分析(2,8,16,36,64进制至10进制相互转换)

本文实例讲述了PHP进制转换。分享给大家供大家参考,具体如下: 可以实现: 10进制转换2、8、16、36、62进制 2、8、16、36、62进制转换10进制 有点要注意下,2、8、1...

PHP中一个有趣的preg_replace函数详解

PHP中一个有趣的preg_replace函数详解

0x01 起因 事情的起因是下午遇到了 preg_replace 函数,我们都知道 preg_replace 函数可能会导致命令执行。现在我们来一些情况。 0x02 经过 踩坑1:...