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 name(){}, for(){}, ….太多了,不说也知道做什么用了。 二、$str{4}在字符串的变量的后面跟上{}刚大括号和中括号一样都是把某个...

wamp安装后自定义配置的方法

WampServer是目前应用非常广泛的PHP集成开发环境,本文就来讲述Wamp安装后自定义配置的方法。供大家参考借鉴。具体如下: wamp2.5安装完毕后,自己手动重新设置了apach...

ZF等常用php框架中存在的问题

从Zend Framework v0.13版本开始,我就开始学习使用Zend Framework。当时公司的一个项目也恰好用到了Zend Fram...

PHP 生成的XML以FLASH获取为乱码终极解决

经过探索最终解决。记录之,顺便也记录了通用解决方案。如果你也遇到XML<->FLASH乱码情况,可以速查: 1.确信XML绝对没有问题的情况: 首先,flash读取xml出现...

php 分库分表hash算法

复制代码 代码如下://分库分表算法 function calc_hash_db($u, $s = 4) { $h = sprintf("%u", crc32($u)); $h1 = i...