当前位置:首页 » 编程语言 » php的header

php的header

发布时间: 2022-10-25 12:52:17

A. php的header问题。

header('Status: 2342');前肯定能输;

ob函数使用标准参考:
ob_start();
........
if ( something ){
ob_end_clean();
header("Location: yourlocation");
exit;
else{
..........
ob_flush(); //省略

要想header前输修改php.ini文件
output_handler =mb_output_handler
或 output_handler =on

B. php中header() 有什么用

header的用法

标头 (header) 是服务器以 HTTP 协义传 HTML 资料到浏览器前所送出的字串,在标头
与 HTML 文件之间尚需空一行分隔。有关 HTTP 的详细说明,可以参 RFC 2068 官方文件
(http://www.w3.org/Protocols/rfc2068/rfc2068)。在 PHP 中送回 HTML 资料前,需先
传完所有的标头。

注意: 传统的标头一定包含下面三种标头之一,并只能出现一次。

Content-Type: xxxx/yyyy
Location: xxxx:yyyy/zzzz
Status: nnn xxxxxx

在新的多型标头规格 (Multipart MIME) 方可以出现二次以上。

使用范例

范例一: 本例使浏览器重定向到 PHP 的官方网站。
Header("Location: http://www.php.net";);
exit;
>?

范例二: 要使用者每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料,可以使用下列的标头
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
>?

范例三: 让使用者的浏览器出现找不到档案的信息。
header("Status: 404 Not Found");
>?

范例四:让使用者下载档案。

header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=文件名\");
header("Content-Description: PHP3 Generated Data");
?>

header重定向 就等价于替用户在地址栏输入url

C. php设置网页头header参数有哪些

header(string,replace,http_response_code)

string 必需。规定要发送的报头字符串。
replace 可选。指示该报头是否替换之前的报头,或添加第二个报头。
默认是 true(替换)。false(允许相同类型的多个报头)。
http_response_code 可选。把 HTTP 响应代码强制为指定的值。(PHP 4 以及更高版本可用)

header("Content-type:text/html;charset=utf-8");

D. php的header 函数怎么用

header就是服务器向浏览器提交的http请求经常用来设置如何处理显示的页面,比如header(“Content-type:text/html;charset=utf8”);接下来要输出的文本全当做html输出并且编码是utf8

E. php中的header(),不起作用。

  1. php的header函数作用是给浏览器发送的HTTP连接请求头中的内容定制,和页面内<meta http-equiv="content-type" content="text/html;charset=gbk" />是两回事。

  2. header设置为image/ipeg的话,内容不是给人阅读的文本,设定文字编码作用不到图片上文字,因为文字也是图片,没有编码了。

  3. 软件没有问题。在图片上写一个GBK或者UTF8编码的文字,似乎没什么意义?

  4. 如果要正常显示,只要保证你所有的字符串都是UTF8就可以了。

F. php的header函数设置在哪

//ok
header(‘HTTP/1.1200OK');
//设置一个404头:
header(‘HTTP/1.1404NotFound');
//设置地址被永久的重定向
header(‘HTTP/1.1301MovedPermanently');
//转到一个新地址
header(‘Location:http://www.example.org/‘);
//文件延迟转向:
header(‘Refresh:10;url=http://www.example.org/‘);
print‘';
//当然,也可以使用html语法实现
//<metahttp-equiv=”refresh”content=”10;http://www.example.org//>
//overrideX-Powered-By:PHP:
header(‘X-Powered-By:PHP/4.4.0′);
header(‘X-Powered-By:Brain/0.6b');
//文档语言
header(‘Content-language:en');
//告诉浏览器最后一次修改时间
$time=time()–60;//orfilemtime($fn),etc
header(‘Last-Modified:‘.gmdate(‘D,dMYH:i:s',$time).'GMT');
//告诉浏览器文档内容没有发生改变
header(‘HTTP/1.1304NotModified');
//设置内容长度
header(‘Content-Length:1234′);
//设置为一个下载类型
header(‘Content-Type:application/octet-stream');
header(‘Content-Disposition:attachment;filename=”example.zip”‘);
header(‘Content-Transfer-Encoding:binary');
//loadthefiletosend:
readfile(‘example.zip');
//对当前文档禁用缓存
header(‘Cache-Control:no-cache,no-store,max-age=0,must-revalidate');
header(‘Expires:Mon,26Jul199705:00:00GMT');//Dateinthepast
header(‘Pragma:no-cache');
//设置内容类型:
header(‘Content-Type:text/html;charset=iso-8859-1′);
header(‘Content-Type:text/html;charset=utf-8′);
header(‘Content-Type:text/plain');//纯文本格式
header(‘Content-Type:image/jpeg');//JPG***
header(‘Content-Type:application/zip');//ZIP文件
header(‘Content-Type:application/pdf');//PDF文件
header(‘Content-Type:audio/mpeg');//音频文件
header(‘Content-Type:application/x-shockw**e-flash');//Flash动画
//显示登陆对话框
header(‘HTTP/1.1401Unauthorized');
header(‘WWW-Authenticate:Basicrealm=”TopSecret”‘);
print‘‘;
print‘enterswronglogindata';

G. php中header()作用

header的用法

标头 (header) 是服务器以 HTTP 协义传 HTML 资料到浏览器前所送出的字串,在标头
与 HTML 文件之间尚需空一行分隔。有关 HTTP 的详细说明,可以参 RFC 2068 官方文件
(http://www.w3.org/Protocols/rfc2068/rfc2068)。在 PHP 中送回 HTML 资料前,需先
传完所有的标头。

注意: 传统的标头一定包含下面三种标头之一,并只能出现一次。

Content-Type: xxxx/yyyy
Location: xxxx:yyyy/zzzz
Status: nnn xxxxxx

在新的多型标头规格 (Multipart MIME) 方可以出现二次以上。

使用范例

范例一: 本例使浏览器重定向到 PHP 的官方网站。
Header("Location: http://www.php.net";);
exit;
>?

范例二: 要使用者每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料,可以使用下列的标头
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
>?

范例三: 让使用者的浏览器出现找不到档案的信息。
header("Status: 404 Not Found");
>?

范例四:让使用者下载档案。

header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=文件名\");
header("Content-Description: PHP3 Generated Data");
?>

header重定向 就等价于替用户在地址栏输入url
---------------------------------
//刚好找到比较详细的资料!

H. php header 怎么设置

PHP设置header示例:

<?php
//设置页面编码
header("Content-type:/text/html;charset=utf-8;");

//页面重定向跳转示例
header("location:index.php");

I. php中的header("Content-type: image/jpeg")是什么意思

php里面header是设定http协议标头的函数。
HTTP协议是基于请求/响应范式的。一个客户机与服务器建立连接后,发送一个请求给服务器。服务器端返回响应,可以告知客户端相关的信息。
header("Content-type: image/jpeg")表明请求页面的内容是jpeg格式的图像。

热点内容
华为平板迅雷存储位置 发布:2025-07-13 11:54:44 浏览:712
javaweb经典 发布:2025-07-13 11:50:25 浏览:416
屏幕切换器怎么配置 发布:2025-07-13 11:49:43 浏览:245
我与预算法 发布:2025-07-13 11:20:28 浏览:426
线谱算法 发布:2025-07-13 11:17:15 浏览:838
怎么把文件上传百度云 发布:2025-07-13 11:09:18 浏览:556
光遇安卓玩家如何加苹果玩家 发布:2025-07-13 11:08:21 浏览:477
安卓哪里下载破解游戏 发布:2025-07-13 11:02:30 浏览:324
三菱如何查找未编译的程序 发布:2025-07-13 11:02:29 浏览:389
2013全国计算机二级c语言真题 发布:2025-07-13 10:58:17 浏览:174