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设计模式之命令模式的深入解析

命令模式(Command),命令模式是封装一个通用操作的机制。 如果你熟悉C或PHP,你可能已经遇到过Command,它相当于程序中的:回调(callback)。回调通常使用一个函数指针...

PHP经典实用正则表达式小结

本文实例讲述了PHP经典实用正则表达式。分享给大家供大家参考,具体如下: 对于开发人员来说,正则表达式是一个非常有用的功能,它提供了 查找,匹配,替换 句子,单词,或者其他格式的字符串。...

php实现有序数组旋转后寻找最小值方法

把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一...

为Plesk PHP7启用Oracle OCI8扩展方法总结

注:本文适用于RHEL/CentOS发行版。 步骤1.安装构建自定义PHP 7模块所需的devel包 # yum install plesk-php70-devel gcc gli...

php无限级分类实现方法分析

本文实例讲述了php无限级分类实现方法。分享给大家供大家参考,具体如下: 1. 递归 public function getInfo(){ $data=$this->selec...