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 empty函数 使用说明

Determine whether a variable is considered to be empty. 但是在我的记忆中,有很长一段时间一直以为empty应该是能够判断一个东西是...

PHP学习笔记(三):数据类型转换与常量介绍

一、PHP数据类型相互转换 1、强制转换 复制代码 代码如下: // bool,int,float,string,array,object,null bool settype ( mix...

20个PHP常用类库小结

图表库 下面的类库可以让你很简的创建复杂的图表和图片。当然,它们需要GD库的支持。 pChart - 一个可以创建统计图的库。 Libchart - 这也是一个简...

PHP如何搭建百度Ueditor富文本编辑器

PHP如何搭建百度Ueditor富文本编辑器

本文为大家分享了PHP搭建百度Ueditor富文本编辑器的方法,供大家参考,具体内容如下 下载UEditor 官网:下载地址 将下载好的文件解压到thinkphp项目中,本文是解压到PU...

PHP处理excel cvs表格的方法实例介绍

复制代码 代码如下: <PRE class=php name="code"><?php $data = array(); //convert a cvs file to...