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

相关文章

WordPress中创建用户角色的相关PHP函数使用详解

WordPress中创建用户角色的相关PHP函数使用详解

WordPress 默认有 “订阅者”、“投稿者”、“作者”、“编辑” 和 “管理员” 五个用户角色,权限由低到高,但默认的五个角色可能不够我们用,这时可以使用 add_role() 函...

详解php中空字符串和0之间的关系

前言 最近在处理关于经纬度的问题时,在建表的时候,选择用字符串varchar存储经度、纬度。为以后的问题埋下伏笔。下面话不多说,我们来看看详细的介绍。 $_x=$row["x"];...

php使用PDO获取结果集的方法

本文实例讲述了php使用PDO获取结果集的方法。分享给大家供大家参考,具体如下: fetch()方法 fetch()方法用于获取结果集的下一行,语法如下: mixed PDOStatem...

PHP中call_user_func_array回调函数的用法示例

call_user_func_array call_user_func_array — 调用回调函数,并把一个数组参数作为回调函数的参数 mixed call_user_func_a...

ASP和PHP实现生成网站快捷方式并下载到桌面的方法

在网站上设置“加入收藏、设为首页”等按钮是一般网站都会干的事儿,但是有的网站还有“放到桌面”这样的功能设置。下面即生成快捷方式并下载到桌面的php实现代码,摘录修改于网络,仅作参考 ph...