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网站被挂木马后的修复方法总结

本文实例总结了php网站被挂木马后的修复方法。分享给大家供大家参考。具体方法如下: 在linux中我们可以使用命令来搜查木马文件,到代码安装目录执行下面命令 复制代码 代码如下:find...

Ubuntu下安装PHP的mongodb扩展操作命令

在 https://pecl.php.net/package/mongo 下载 PHP的mongodb扩展的源码 复制代码 代码如下: $ wget -c https://pecl.ph...

PHPExcel冻结(锁定)表头的简单实现方法

PHPExcel冻结(锁定)表头的简单实现方法

本文实例讲述了PHPExcel冻结(锁定)表头的简单实现方法。分享给大家供大家参考,具体如下: PHPExcel是一款功能比较强大的操作微软excel的PHP插件,在导出数据时为了方便查...

php使用PDO获取结果集的方法

本文实例讲述了php使用PDO获取结果集的方法。分享给大家供大家参考,具体如下: fetch()方法 fetch()方法用于获取结果集的下一行,语法如下: mixed PDOStatem...

php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法【与函数nl2br功能相反】

本文实例讲述了php自定义函数br2nl实现将html中br换行符转换为文本输入中换行符的方法。分享给大家供大家参考,具体如下: 下面这几个方法将能够帮你解决这个问题。 PHP版将htm...