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 进行开发的过程中,或早或晚,您会需要创建许多相似的变量,这时候你可以把数据作为元素存储在数组中。数组中的元素都有自己的 ID,因此可以方便地访问它们。 关联数组 关联数组...

php数组的一些常见操作汇总

数组求和 给定一个含有n个元素的整型数组a,求a中所有元素的和。可能您会觉得很简单,是的,的确简单,但是为什么还要说呢,原因有二,第一,这道题要求用递归法,只用一行代码。第二,这是我人生...

PHP中有关长整数的一些操作教程

PHP中有关长整数的一些操作教程

前言 在PHP,数字类型只有int和float两种,它们的位数取决于系统,而且没有uint,所以跟其它系统通信的时候就有诸多不便。如果int溢出,则自动转换为float,用科学计数法来表...

几款免费开源的不用数据库的php的cms

1、MuCMS一个小型,平台独立的内容管理系统适用于非交互式网站(网站只发布信息)。它对系统要求非常低,只需要Apache+PHP。没有使用数据库。它具有安全,快速,易用等特点。官方网站...

php和nginx交互实例讲解

php和nginx交互实例讲解

Nginx与PHP交互过程的7步走(用户对动态PHP网页访问过程) step1:用户将http请求发送给nginx服务器(用户和nginx服务器进行三次握手进行TCP连接)。...