php download.php实现代码 跳转到下载文件(response.redirect)
作者:bea
跳转核心代码实现。 代码如下: 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 > ...
跳转核心代码实现。
代码如下:
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: http:///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
有用 | 无用
代码如下:
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: http:///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 数组遍历顺序理解
- PHP 裁剪图片成固定大小代码方法
- PHP 获取MSN好友列表的代码(2009-05-14测试通过)
- PHP 危险函数全解析
- php 获取远程网页内容的函数
- php 遍历数据表数据并列表横向排列的代码
- 不要轻信 PHP_SELF的安全问题
- php中$_SERVER[PHP_SELF] 和 $_SERVER[SCRIPT_NAME]之间的区别
- php getsiteurl()函数
- PHP 内存缓存加速功能memcached安装与用法
- 用PHP读取flv文件的播放时间长度
- 用php将任何格式视频转为flv的代码
- ajax php 实现写入数据库
- JieqiCMS 杰奇1.5注册机php源码
- 自动把纯文本转换成Web页面的php代码
- PHP高级OOP技术演示
- php 获取可变函数参数的函数
- PHP类(Class)入门教程