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获取错误信息的方法。分享给大家供大家参考。具体如下: function error_reg(){ $ar=array( E_ERROR => 'err...

PHP使用ob_start生成html页面的方法

本文实例讲述了PHP使用ob_start生成html页面的方法。分享给大家供大家参考。具体方法分析如下: ob_start([string output_callback])- 打开输出...

PHP实现对图片的反色处理功能【测试可用】

PHP实现对图片的反色处理功能【测试可用】

本文实例讲述了PHP实现对图片的反色处理功能。分享给大家供大家参考,具体如下: 今天有个需求用php对图片进行反色,和转灰,之前不知道可不可行,后来看到了imagefilter()函数,...

php设计模式 Delegation(委托模式)

复制代码 代码如下: <?php /** * 委托模式 示例 * * @create_date: 2010-01-04 */ class PlayList { var $_song...

php实现基于PDO的预处理示例

本文实例讲述了php实现基于PDO的预处理。分享给大家供大家参考,具体如下: $servername="localhost"; $username="root"; $password...