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内存相关的功能特性详解

可能有的读者碰到过类似下面的错误吧:Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y...

php实现的网页版剪刀石头布游戏示例

php实现的网页版剪刀石头布游戏示例

本文实例讲述了php实现的网页版剪刀石头布游戏。分享给大家供大家参考,具体如下: <?php /* * Created on 2016-11-25 * */ i...

PHP mcrypt可逆加密算法分析

数据加密在我们生活中的地位已经越来越重要了,尤其是考虑到在网络上发生的大量交易和传输的大量数据。对于不需要还原为原始数据的信息我们可以使用MD5、sha1等不可逆加密算法对数据进行加密处...

php 设计模式之 单例模式

小船类boat.php复制代码 代码如下:<?php class boat { private static $instance=null; private $skipper; p...

php 文本文件的读取效率

首页大概3KB,是在本地测试的 复制代码 代码如下: file_get_contents('shadow.xml'); 耗时 0.0003 秒 复制代码 代码如下: $indexFil...