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实现享元模式(flyweight)

学习php设计模式 php实现享元模式(flyweight)

一、意图 运用共享技术有效的支持大量细粒度的对象 享元模式变化的是对象的存储开销 二、享元模式结构图 三、享元模式中主要角色 抽象享元(Flyweight)角色:此角色是所有的具体享元...

php实现QQ空间获取当前用户的用户名并生成图片

本文实例讲述了php实现QQ空间获取当前用户的用户名并生成图片的方法。分享给大家供大家参考。具体如下: 最近发现空间里经常会转载一些含有当前用户昵称和qq号的图片,很好奇,研究了一下原理...

php版微信数据统计接口用法示例

php版微信数据统计接口用法示例

本文实例讲述了php版微信数据统计接口用法。分享给大家供大家参考,具体如下: php版微信数据统计接口其实是非常的好用了在前版本还没有此功能是后面的版本增加上去了,下面来看一个php版微...

php字符串截取中文截取2,单字节截取模式

//中文截取2,单字节截取模式 function cn_substr($str,$slen,$startdd=0){     $re...

PHP生成图像验证码的方法小结(2种方法)

本文实例讲述了PHP生成图像验证码的方法。分享给大家供大家参考,具体如下: 1、生成加法运算验证码图片 session_start (); /*定义头文件为图片*/ header("...