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读取数据库并按照中文名称进行排序实现代码

有时候我们读取数据库输出的时候可能会需要按照中文用户名的方式进行排序,传统的MySQL查询代码如下: 复制代码 代码如下: $sql="SELECT * FROM users";//传统...

php开发中的页面跳转方法总结

页面跳转可能是由于用户单击链接、按钮等触发的,也可能是系统自动产生的。页面自动跳转在WEB开发中经常用到,而且根据需求可以采用不同的跳转方式,比如提示操作信息后延时跳转等, 本文总结了W...

PHP判断数据库中的记录是否存在的方法

本文实例讲述了PHP判断数据库中的记录是否存在的方法。分享给大家供大家参考。 具体实现代码如下: 复制代码 代码如下: <?php    $sql=...

PHP随机字符串生成代码(包括大小写字母)

第一种:利用字符串函数操作 复制代码 代码如下: <?php function createRandomStr($length){ $str = '0123456789abcdef...

PHP简单获取随机数的常用方法小结

本文实例讲述了PHP简单获取随机数的常用方法。分享给大家供大家参考,具体如下: 1.直接获取从min-max的数,例如1-20: $randnum = mt_rand(1, 20);...