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中英混合字符串截取函数代码

复制代码 代码如下: function get_word($string, $length, $dot = '..',$charset='gbk') { if(strlen($strin...

如何使用Linux的Crontab定时执行PHP脚本的方法

下面介绍Crontab的两种方法。 一、在Crontab中使用PHP执行脚本 就像在Crontab中调用普通的shell脚本一样(具体Crontab用法),使用PHP程序来调用PHP脚本...

浅析PHP中Collection 类的设计

用.net开发已经很多年了,最近接触到php,发现php也很好玩。不过发现它里面没有集合Collection类,只有数组,并且数组很强。这里我用数组来包装成一个集合Collection,...

做了CDN获取用户真实IP的函数代码(PHP与Asp设置方式)

asp函数代码:复制代码 代码如下:function checkip(checkstring)'用正则判断IP是否合法dim re1set re1=new RegExpre1.patte...

PHP实现上传图片到数据库并显示输出的方法

PHP实现上传图片到数据库并显示输出的方法

本文实例讲述了PHP实现上传图片到数据库并显示输出的方法。分享给大家供大家参考,具体如下: 1. 创建数据表 CREATE TABLE ccs_image ( id int(4)...