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中session定期自动清理的方法

下文来为各位介绍PHP设置session定期自动清理的例子了,因为session默认是15分钟自动把变量给清除内存了,但有一些时间并不生效了,下面我们就来看看。 配置完成php后默认ph...

php htmlspecialchars加强版

复制代码 代码如下: //取消HTML代码 function shtmlspecialchars($string) { if(is_array($string)) { foreach($...

php接口与接口引用的深入解析

1、接口的介绍与创建 关键字 :interface 2、接口的引用与规范 关键字 :implements 接口:一种成员属性全...

写出高质量的PHP程序

一、安全 无论程序写的如何,首先安全是第一位的,没有安全保障的程序根本不能谈高质量。 二、稳定 无论你代码写的再烂,必须要能稳定运行。 三、用户体验 用户的体验直接决定着一个程序的命运,...

详解PHP原生DOM对象操作XML的方法

一、创建 创建一个新的XML文件,并且写入一些数据到这个XML文件中。 /* * 创建xml文件 */ $info = array( array('obj' => '...