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中eval函数的危害与正确禁用方法

php的eval函数并不是系统组件函数,因此我们在php.ini中使用disable_functions是无法禁止它的。 但是eval()对于php安全来说具有很大的杀伤力,因此一般不用...

php连接mssql的一些相关经验及注意事项

为了能让PHP连接MSSQL,系统需要安装MSSQL,PHP,且在PHP.ini中的配置中,将 ;extension=php_mssql.dll前面的;去掉 1.连接MSSQL 复制代码...

利用PHP判断是否是连乘数字串的方法示例

描述 有这样一道题,给出一个数字串A,需要判断A是否为连乘数字串,连乘数字串的定义就是一个数字串可以拆分成若干个数字,后面的数字(从第N个数字开始)为前面2个数字的乘积。 举例 (1)...

PHP消息队列实现及应用详解【队列处理订单系统和配送系统】

PHP消息队列实现及应用详解【队列处理订单系统和配送系统】

本文实例讲述了PHP消息队列实现及应用。分享给大家供大家参考,具体如下:在互联网项目开发者经常会遇到『给用户群发短信』、『订单系统有大量的日志需要记录』或者在秒杀业务的时候服务器无法承受瞬...

php数组合并与拆分实例分析

本文实例讲述了php数组合并与拆分的方法。分享给大家供大家参考。具体如下: <?php $array1 = array("A","B","C","D"); $arr...