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应用当中,二维数组的应用算是高频率的了,尤其遇到较为复杂的计算时,基本上都要用到二维或者多维数组的,而在编历多维数组使用的较多的应该是 for 循环遍历和 foreach 遍历两...

php简单实现多语言切换的方法

本文实例讲述了php简单实现多语言切换的方法。分享给大家供大家参考,具体如下: 1.主程序代码: <?php include "lib/function.php"; &...

PHP开发的一些注意点总结

Linux系统的使用 现在标配的系统是 Linux + Nginx + PHP + MySQL ,这样的配置越来越多的大公司在用的了说到配置不同的是一个公司的规约,比如说挂载一般分为2个...

php二维数组合并及去重复的方法

本文实例讲述了php二维数组合并及去重复的方法。分享给大家供大家参考。具体实现方法如下: $arr = array_merge($labels,$label); //合并需要合并的俩...

php获取客户端电脑屏幕参数的方法

本文实例讲述了php获取客户端电脑屏幕参数的方法。分享给大家供大家参考。具体分析如下: 首先需要说明的是php是服务器端的语言,是获取不到客户端的屏幕的宽度和高度的。但是有变通的方法就是...