html问题,浏览器怎么设置header

html问题,浏览器怎么设置header,第1张

html问题,浏览器怎么设置header,简单点说,将是想用浏览器(客户端)发一个数据 。

header() 函数向客户端发送原始的 http 报头。认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数。

方法/步骤

1、定义和用法

header() 函数向客户端发送原始的 http 报头。

认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数(在 php教程 4 以及更高的版本中,您可以使用输出缓存来解决此问题):

<html>

实例一

代码如下复制代码

<?php # script 2.7 - view_tasks.php

// connect to the database:

$dbc = @mysql教程i_connect ('localhost', 'username', 'password', 'test') or die ('<p>could not connect to the database!</p></body></html>')

// get the latest dates as timestamps教程:

$q = 'select unix_timestamp(max(date_added)), unix_timestamp(max(date_completed)) from tasks'

$r = mysqli_query($dbc, $q)

list($max_a, $max_c) = mysqli_fetch_array($r, mysqli_num)

// determine the greater timestamp:

$max = ($max_a >$max_c) ? $max_a : $max_c

// create a cache interval in seconds:

$interval = 60 * 60 * 6// 6 hours

// send the header:

header ("last-modified: " . gmdate ('r', $max))

header ("expires: " . gmdate ("r", ($max + $interval)))

header ("cache-control: max-age=$interval")

?>

实例二

代码如下复制代码

<?php

// 结果出错

// 在调用 header() 之前已存在输出

header('location: http://www./')

?>语法

header(string,replace,http_response_code)

提示用户保存一个生成的 pdf 文件(content-disposition 报头用于提供一个推荐的文件名,并强制浏览器显示保存对话框):

代码如下复制代码

<?php

header("content-type:application/pdf")

// 文件将被称为 downloaded.pdf

header("content-disposition:attachmentfilename='downloaded.pdf'")

// pdf 源在 original.pdf 中

readfile("original.pdf")

?>

<html>

<body>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312"><!--设置网页的文件编码-->

<meta http-equiv="expires" content="2005/05/05 18:00:00"><!--脱机浏览的过期时间-->

<meta http-equiv="pragma" content="no-cache"><!--禁止网页从缓存中读取-->

<meta http-equiv="Refresh" content="5http://#/"><!--网页重新定向-->

<meta http-equiv="set-cookie" content="2005/05/05 18:00:00"><!--设置网页的cookie过期时间-->

<meta http-equiv="Window-target" content="_top"><!--设置网页中链接的目标窗口-->

<meta http-equiv="Page-Enter" content="revealTrans(duration=1000000,transition=50000000)"><!--设置网页的打开效果-->

<meta http-equiv="Page-Exit" content="revealTrans(duration=1000000,transition=50000000)"><!--设置网页的关闭效果-->

<meta name="keywords" content="overmind,zerg,protoss"><!--设置网页的关键字,搜索的时候优先!!!重要!!! 该数据被搜索引擎编入索引-->

<meta name="description" content="哈哈哈哈哈"><!--插入描述 搜索时被搜索引擎编入索引-->

<title>无标题文档</title>

</head>

这是HTML5的新标签,这样写语义上是表示页面布局的头部。头部就是一般放LOGO和菜单导航的部分。

IE8或以下版本都不支持HTML5,但在其他所有主流浏览器中得到支持(国内基于IE内核的浏览器除外)。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11470889.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存