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实现的博客欢迎提示功能(很特别哦)

以下代码的实现效果: 1、留言的访客显示欢迎词2、一般访客来源提示3、不留言潜水党(刷新大于7次,催促留言)4、针对IE的推送更新提示 使用方法:调用相应的函数,例如welcome_ms...

PHP实现通过正则表达式替换回调的内容标签

本文实例讲述了PHP实现通过正则表达式替换回调的内容标签。分享给大家供大家参考。具体实现方法如下: function my_wp_plugin_tag_action($content...

php PDO判断连接是否可用的实现方法

mysql_ping() 检查到服务器的连接是否正常。如果到服务器的连接可用,则返回true,否则返回false。 但PDO不支持mysql_ping()方法,因此需要自己编写代码模拟m...

php中var_export与var_dump的区别分析

一 var_dump (PHP 3 >= 3.0.5, PHP 4, PHP 5) var_dump -- 打印变量的相关信息 描述 void var_dump ( mixed e...

php导出excel格式数据问题

解决2个问题:1.身份证之类的文本数据自动转为科学计数法的问题。2.中文乱码的问题 excel从web页面上导出的原理。当我们把这些数据发送到客户端时,我们想让客户端程序(浏览器)以ex...