php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com5年前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数组函数序列之array_slice() - 在数组中根据条件取出一段值,并返回

array_slice()定义和用法 array_slice() 函数在数组中根据条件取出一段值,并返回。 注释:如果数组有字符串键,所返回的数组将保留键名。(参见例子 4) 语法 ar...

php fsockopen伪造post与get方法的详解

fsockopen 伪造 post和get方法哦,如果你正在找 伪造 post和get方法的php处理代码这款不错哦。复制代码 代码如下:<?php//fsocket模拟post提...

php通过文件流方式复制文件的方法

本文实例讲述了php通过文件流方式复制文件的方法。分享给大家供大家参考。具体分析如下: php的stream_copy_to_stream()函数可以被用来将一个流中的数据复制到另一个。...

关于Sphinx创建全文检索的索引介绍

全文检索的索引创建过程一般有以下几步:1、一些需要创建索引的文档(Documents)。 2、将原文档传给分词组件(Tokenizer)。 3、将得到的词元(Token)传给语言处理组件...

php代码架构的八点注意事项

本文总结讲述了php代码架构的八点注意事项。分享给大家供大家参考,具体如下: 写代码写了6年多了,看看以前的架构,看看现在的架构。都有一些不足的地方。不管怎么样,都一直在改进。说实话不太...