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实现的简单美国商品税计算函数。分享给大家供大家参考。具体如下: <?php function tax($total,$tax_amount){...

PHP后期静态绑定之self::限制实例分析

本文实例讲述了PHP后期静态绑定之self::限制。分享给大家供大家参考,具体如下: 在此我想讲一讲后期静态绑,我想讲self::与static进行比较说明。 官方文档上是这样定义的:...

php方法调用模式与函数调用模式简例

现有某函数与对象如下: 复制代码 代码如下: var doubling=function(x){ return x*2; }; var obj={ val:100, }; 函数调用模式...

PHP获取数组中单列值的方法

本文实例讲述了PHP获取数组中单列值的方法。分享给大家供大家参考,具体如下: PHP中获取数组中单列的值如下: 利用PHP中的数组函数 array_column():返回数组中某个单列的...

PHP CodeBase:将时间显示为&quot;刚刚&quot;&quot;n分钟/小时前&quot;的方法详解

在很多场合为了显示出信息的及时性,一般会将时间显示成“刚刚”,“5分钟前”,“3小时前”等,而不是直接将时间打印出来。比如微博,SNS类应用就最长用到这个功能。而一般存储在数据库中的时间...