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实现Mongodb自定义方式生成自增ID的方法

本文实例讲述了php实现Mongodb自定义方式生成自增ID的方法。分享给大家供大家参考。具体分析如下: 复制代码 代码如下://首先创建一个自动增长id集合 ids >db.id...

php中引用符号(&amp;)的使用详解

与C语言中的指针是有差别的.C语言中的指针里面存储的是变量的内容在内存中存放的地址变量的引用.PHP 的引用允许你用两个变量来指向同一个内容 复制代码 代码如下:$a="ABC"; $b...

php删除与复制文件夹及其文件夹下所有文件的实现代码

复制代码 代码如下:<?php  /*复制xCopy函数用法:      *   xCopy("feiy","...

简要剖析PHP的Yii框架的组件化机制的基本知识

简要剖析PHP的Yii框架的组件化机制的基本知识

组件是 Yii 应用的主要基石。是 yii\base\Component 类或其子类的实例。三个用以区分它和其它类的主要功能有: 属性(Property) 事件(Event)...

PHP6 中可能会出现的新特性预览

  这些特性包括:     集成OpCache(OPcache通过对PHP的opcode进行缓存和优化,可以提高PHP程序的执行速度) ...