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

相关文章

asp函数split()对应php函数explode()

<?php //利用 explode 函数分割字符串到数组 $source = "hello1,hello2,hello3,hello4,hello5";//按逗号分离...

PHP自定义错误用法示例

本文实例讲述了PHP自定义错误用法。分享给大家供大家参考,具体如下: 自定义错误就是自己可以完全控制错误以及其提示内容 设定错误由自己定义的函数来处理 set_error_handl...

php打印一个边长为N的实心和空心菱型的方法

本文实例讲述了php打印一个边长为N的实心和空心菱型的方法。分享给大家供大家参考。具体分析如下: 实心菱型计算方法: $n:边长 $i:当前行,0开始 $rows:总行数 上部 前面空格...

php多进程模拟并发事务产生的问题小结

前言 本文通过实例代码给大家介绍了关于php多进程模拟并发事务产生的一些问题,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧 表 drop table if exi...

php-cli简介(不会Shell语言一样用Shell)

1.基础知识 1.1 什么是Shell编程? 在 Unix 中,shell 可不是简单的命令解释器(典型的有 Windows 中的 DOS ),而是一个全功能的编程环境。Shell 是操...