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添加PNG图片背景透明水印操作类定义与用法示例

本文实例讲述了PHP添加PNG图片背景透明水印操作类定义与用法。分享给大家供大家参考,具体如下: 图片相关操作类 class ImageTool { private $image...

php进行md5加密简单实例方法

直接可以使用md5()函数,对内容进行加密,如:md5($admin_pw) 把这段密文分割成若干段,对每段都进行一次MD5运算,然后把这堆密文连成一个超长的字符串,最后再进行一次MD5...

PHP实现时间轴函数代码

本文将介绍如何实现基于时间轴的时间的转换。 首先我们要明白时间的几个函数: time():返回当前的 Unix 时间戳 date():格式化一个本地时间/日期。 应用举例: 复制代码 代...

discuz Passport 通行证 整合笔记

discuz Passport 通行证 整合笔记

太简单了,但时间长了,记不得,浪费我半小时找资料,深刻体会好记性不如烂笔头!!今天把passport文挡贴上,防止以后忘记!!记住,网上找到自己需要的资料也要耗时间的!!!!!! Pas...

PHP进阶学习之反射基本概念与用法分析

PHP进阶学习之反射基本概念与用法分析

本文实例讲述了PHP进阶学习之反射基本概念与用法。分享给大家供大家参考,具体如下: 一、前言 Reflection(反射)是Java程序开发语言的特征之一,它允许运行中的Java程序对自...