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 header("Content-type: text/html; charset=utf-8"); function multiple_repla...

php去除html标记的原生函数详解

     strip_tags 去掉 HTML 及 PHP 的标记。 语法: string strip_tags(string str); 传回值...

GBK的页面输出JSON格式的php函数

复制代码 代码如下:function tb_json_encode($value, $options = 0) { return json_encode(tb_json_convert_...

php中使用addslashes函数报错问题的解决方法

大家看下面的代码,能发现错误在哪里吗? 复制代码 代码如下:<?phpecho function_exists('addcslashes');//检测是否存在该函数echo get...

php5.3不能连接mssql数据库的解决方法

本文实例讲述了php5.3不能连接mssql数据库的解决方法。分享给大家供大家参考。具体分析如下: 自从php5.3之后系统就不支持mssql_connect这个函数连接了,以前我也讲可...