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 七大优势分析

虽然ASP是一种不错的技术,但从长远考虑我相信PHP在将来的技术领域里会有不凡的表现。   我认为有七个理由可以说明PHP比ASP更优秀:   1、速度、速度、速度   当我第一次运行P...

shopex中集成的站长统计功能的代码简单分析

复制代码 代码如下: <?php //我们的域名,这里可以不唯一的 $domain = 'localhost'; //这个应该是CNZZ授权给shopex的加密密钥,如果错了就不能...

PHP实现浏览器中直接输出图片的方法示例

本文实例讲述了PHP实现浏览器中直接输出图片的方法。分享给大家供大家参考,具体如下: 在浏览器中输出图片,最简单的方法当然是使用HTML的img标签,直接传入图片路径或者链接。但有时候我...

php获取网页请求状态程序示例

对于网页返回状态代码一般情况下我们都会去查自己网站状态码是不是200或错误页面是不是404代码,并且多数情况下我们的查看方法就是使用站长工具或ff浏览器等来查看,极少有人想到自己写一个查...

PHP高级对象构建 工厂模式的使用

PHP设计模式工厂模式的使用方法 复制代码 代码如下: <?php /* * 每日练习 PHP设计模式工厂模式的使用方法 * PHP工厂模式不难理解,顾名思义,就是一个加工厂,然后...