PHP中header的作用

1、跳转

//若等待时间为0,则与header("location:")等效。 
//Header("Location:http://localhost//session.php");直接跳转

2、指定网页的内容

3、附件


   下载:

    $filename = "tupian.jpg"; //文件路径  可以绝对路径也可以相对路径
   header('Content-type: application/x-jpg'); //文件的类型 http://www.w3school.com.cn/media/media_mimeref.asp
header('Content-Disposition: attachment; filename="保存时的文件名.jpg"'); //下载显示的名字 
readfile("$filename"); 
exit(); 

pg"; //文件路径//

octet-stream'); //文件的类型 octet-stream readfile("$filename"); 
exit(); 

     查看:

$link = "tupian.jpg"; //文件路径  可以绝对路径也可以相对路径

//$link = "新建文本文档.xml"; //文件路径  可以绝对路径也可以相对路径
if (isset($link)) 
                { 
                    Header("HTTP/1.1 303 See Other"); 
                    Header("Location: $link"); 
                    exit; 
                } 

 
0
0
posted @ 2016-07-01 19:20  limeng951  阅读(163)  评论(0编辑  收藏  举报