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中PCRE正则解析代码详解

一、前言 前面的博客里,有对字符集的解析。这里就不是字符集的事儿了,在PHP中很多函数的处理默认是unicode中的UTF-8编码格式。那么废话不多说,直接开始正题。 二、PHP函数mb...

PHP递归统计系统中代码行数

本文实例为大家分享了PHP递归统计系统中代码行数的具体代码,供大家参考,具体内容如下 1、统计代码行数,必然用到的两个关键的知识点:函数递归以及文件读取。 函数递归无非就是在函数的代码中...

PHP封装类似thinkphp连贯操作数据库Db类与简单应用示例

本文实例讲述了PHP封装类似thinkphp连贯操作数据库Db类与简单应用。分享给大家供大家参考,具体如下: <?php header("Content-Type:te...

php实现上传图片文件代码

代码很简单,这里我们就不多废话了,直接奉上源码 <?php // 注册表单的姓名 $name=""; $nameErr=""; if ($_SERVER["REQUES...

WordPress中编写自定义存储字段的相关PHP函数解析

WordPress中编写自定义存储字段的相关PHP函数解析

WordPress 的自定义字段就是文章的 meta 信息(元信息),利用这个功能,可以扩展文章的功能,是学习 WordPress 插件开发和主题深度开发的必备知识,方便给文章储存一些额...