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编程注意事项的小结

 1、php隐性的三元操作符(?:)优先级问题: 例1:复制代码 代码如下:    $person = $who or $person = "la...

解析使用substr截取UTF-8中文字符串出现乱码的问题

我们知道有时候使用substr来截取UTF-8中文字符串的时候,经常会出现乱码,为什么会出现这样的问题呢,本文告诉你答案。看这样一段代码吧(字符编码为UTF-8): 复制代码 代码如下:...

php报表之jpgraph柱状图实例代码

php报表之jpgraph柱状图实例代码

新手初识jpgraph肯定会遇到各种各样的问题,比如乱码什么的,本案例是jpgraph3.0.7制作,也经过本人的多次实验,解决乱码问题 复制代码 代码如下: <?php $dat...

php安装ssh2扩展的方法【Linux平台】

本文实例讲述了php安装ssh2扩展的方法。分享给大家供大家参考,具体如下: wget http://www.libssh2.org/download/libssh2-1.4.2.t...

PHP浮点比较大小的方法

本文实例讲述了PHP浮点比较大小的方法。分享给大家供大家参考,具体如下: <?php /** * 浮点数一般是不能用来比较大小的,但是我们可以用一种变通的的方式 *...