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

相关文章

php5.3 注意事项说明

php5.3新特性1.支持命名空间(namespace)5.3以前复制代码 代码如下:<?phpclass Zend_Db_Table_Select {//表示当前这个类文件位于Z...

PHP nl2br函数 将换行字符转成 &amp;lt;br&amp;gt;

将换行字符转成 <br> 。 语法 : string nl2br(string string); 返回值 : 字符串 函数种类 : 资料处理 内容说明 本函数将换行字符转换成...

highchart数据源纵轴json内的值必须是int(详解)

var users = ["0","0","0","0","0","2","0"]; 这样的纵轴数据是不显示的,json里面的值必须是int类型。 必须是这样: var...

php中用socket模拟http中post或者get提交数据的示例代码

废话不多说。直接上代码:sock_post.php:复制代码 代码如下:<?phpfunction sock_post($url, $data='') {  $url =...

PHP会话处理的10个函数

PHP会话处理的10个函数

在PHP开发中,比起Cookie,Session 是存储在服务器端的会话,相对安全,并且不像 Cookie 那样有存储长度限制,这里我们详细介绍一下PHP处理会话函数将要用到10个函数。...