php专区

 首页 > php专区 > PHP基础 > 函数 > 整理php的header函数之设置content-type

整理php的header函数之设置content-type

分享到:
【字体:
导读:
         摘要:设置常用的content-type整理php的header函数之设置content-type...

整理php的header函数之设置content-type
整理php的header函数之设置content-type

//定义编码
header( 'Content-Type:text/html;charset=utf-8 ');

//Atom
header('Content-type: application/atom+xml');

//CSS
header('Content-type: text/css');

//Javascript
header('Content-type: text/javascript');

//JPEG Image
header('Content-type: image/jpeg');

//JSON
header('Content-type: application/json');

//PDF
header('Content-type: application/pdf');

//RSS
header('Content-Type: application/rss+xml; charset=ISO-8859-1');

//Text (Plain)
header('Content-type: text/plain');

//XML
header('Content-type: text/xml');

// ok
header('HTTP/1.1 200 OK');

//设置一个404头:
header('HTTP/1.1 404 Not Found');

//设置地址被永久的重定向
header('HTTP/1.1 301 Moved Permanently');

//转到一个新地址
header('Location: http://www.example.org/');

//文件延迟转向:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';

//当然,也可以使用html语法实现
// 

		          	整理php的header函数之设置content-type
分享到:
PHP里10个鲜为人知但却非常有用的函数
PHP里10个鲜为人知但却非常有用的函数PHP里有非常丰富的内置函数,很多我们都用过,但仍有很多的函数我们大部分人都不熟悉,可它们却十分的有用。这篇文章里,我列举了一些鲜为人知但会让你眼睛一亮的PHP函数。 levenshtein() 你有没有经历过需要知道两个单词有多大的不同的时候,这个函数就是来帮你解决这个问题的。它能比...
大话PHP:6种GET和POST请求发送方法
大话PHP:6种GET和POST请求发送方法 在i94web博客中,我试过了畅言和多说两种社会化评论框,后来还是抛弃了畅言,不安全。 无论是畅言还是多说,我都需要从远程抓取文章的评论数,然后存入本地数据库。对于多说,请求的格式如下: // 获取评论次数,参数是文章ID  function getCommCount($postid)  {      $jsond...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……