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]实用函数9

//执行输入 command 的外部程式或外部指令。返回 string 只是外部程式执行后传回的最后一行;若需要完整地返回信息,可以使用 ...

深入理解:单一入口、MVC、ORM、CURD、ActiveRecord概念

MVC MVC是一个设计模式,它强制性的使应用程序的输入、处理和输出分开。使用MVC应用程序被分成三个核心部件:模型(M)、视图(V)、控制器(C),它们各自处理自己的任务。 视图 :...

php 自定义错误日志实例详解

php 自定义错误日志  项目中需要对定义错误日志及时处理, 那么就需要修改自定义错误日志的输出方式(写日志、发邮件、发短信)   一. register_shutd...

如何让PHP编码更加好看利于阅读

写出优秀的程序代码是一门艺术,要想如此,就必须在一开始就养成良好的编程习惯。良好的编程习惯不仅有助于项目初期的设计(如模块化),还可以使你编写的代码更易于理解,从而使代码的维护工作更轻松...

PHP自定义函数获取汉字首字母的方法

本文实例讲述了PHP自定义函数获取汉字首字母的方法。分享给大家供大家参考,具体如下: 首字母很重要,可以进行排序使用。 城市列表等等。 <?php /* * Creat...