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不用内置函数对数组排序,可能是降序或者升序 第一种方法:传说中的冒泡法 复制代码 代码如下: function...

基于PHP array数组的教程详解

定义数组数组array是一组有序的变量,其中每个变量被叫做一个元素。一、定义数组 可以用 array() 语言结构来新建一个数组。它接受一定数量用逗号分隔的 key => valu...

微信公众平台开发教程④ ThinkPHP框架下微信支付功能图文详解

微信公众平台开发教程④ ThinkPHP框架下微信支付功能图文详解

本文实例讲述了ThinkPHP框架下微信支付功能。分享给大家供大家参考,具体如下: 声明:原文主要摘自白俊遥博客 ,部分内容针对个人事例已作修改,主要用于自己的参考,欢迎指正...

PHP使用PDO操作sqlite数据库应用案例

本文实例讲述了PHP使用PDO操作sqlite数据库。分享给大家供大家参考,具体如下: 1、需求: 已知: 1)、一个json文件,里面是一个二维数组,数组解析出来为: array...

怎么在Windows系统中搭建php环境

怎么在Windows系统中搭建php环境

PHP介绍:PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序...