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关联数组快速排序的方法。分享给大家供大家参考。具体如下: <?php function qsort($a,$f) { qsort_do(&$a,...

解析PHP强制转换类型及远程管理插件的安全隐患

远程管理插件是目前广受WordPress站点管理员欢迎的实用工具,它允许用户同时对多个站点执行相同的操作,如更新到最新的发行版或安装插件等。但是,为了实现这些操作,客户端插件需要赋予远程...

浅析Dos下运行php.exe,出现没有找到php_mbstring.dll 错误的解决方法

在php.ini文件中将 extension=php_mbstring.dll 移动到 extension=php_exif.dll 之前. 因为 exif 要调用 mbstring,...

php定期拉取数据对比方法实例

写在前面 今天在网上看帖子提问的时候,看到有人发表了一个提问 php下载远程的批量文件,每天一次,对比昨天和今天的文件,将旧文件替换成新文件 我们通过这个问题来分析讲解一下其中的知...

php下关于中英数字混排的字符串分割问题

在网上找了一点时间,发现都不怎样。 后来就自己想了个办法,算是原创吧。 只是用截取加替换的功能。 复制代码 代码如下: function smssubstr($string, $leng...