`

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

    博客分类:
  • php
 
阅读更多

一般情况下,html里可以通过使用<meta http-equiv="Content-Type" content="text/html; charset=utf-8">来定义浏览器解析页面的编码方式,

但是,在网站开发中,会出现一种情况,就是在不符合访问条件时,在php里面会直接echo一段提示(非html页面),例如,|||||echo "您没有权限";||||| ,此时直接打印会根据浏览器自己设置的编码方式进行解析,为避免出现乱码,可以使用header("Content-Type:text/html;charset=utf-8");

分享到:
评论

相关推荐

    php基于Snoopy解析网页html的方法

    本文实例讲述了php基于Snoopy解析网页... charset=utf-8"); require_once './Snoopy.php'; $snoopy = new Snoopy(); //$uri = 'http://www.juzimi.com/meitumeiju'; $uri = 'http://www.juzimi.com/meitumeiju?page=1'

    为何要小心Nginx的add_header指令详解

    前言 大家都知道,nginx配置文件通过使用add_header指令来设置... charset=UTF-8 vary: Accept-Encoding, Cookie cache-control: max-age=3, must-revalidate last-modified: Thu, 07 Feb 2019 03:54:54 GMT X-Cach

    php接口数据加密、解密、验证签名

    charset=utf-8’); include_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.’phpsec’.DIRECTORY_SEPARATOR.’Math’.DIRECTORY_SEPARATOR.’BigInteger.php’); include_once(dirname(dirname(__FILE__))....

    云之讯发送短信接口

    charset=utf-8"); //短信验证码(模板短信),默认以65个汉字(同65个英文)为一条(可容纳字数受您应用名称占用字符影响),超过长度短信平台将会自动分割为多条发送。分割后的多条短信将按照具体占用条数计费。 //...

    php分页代码学习示例分享

    charset=utf-8”); //数据库连接 $conn = mysql_connect(“localhost”, “root”, “111”) or die(“not connnected : “.mysql_error()); mysql_select_db(“test”, $conn); mysql_query(“set names utf8”...

    sphinxapi.php

    charset=UTF-8'); error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE); require 'sphinxapi.php'; $cl = new SphinxClient(); $cl-&gt;SetServer('192.168.1.1', 9312); //注意这里的主机 if (! $cl-&gt;open ())...

    php中header设置常见文件类型的content-type

    在PHP中可以通过header函数来发送头...charset=utf-8 '); //Atom header('Content-type: application/atom+xml'); //CSS header('Content-type: text/css'); //Javascript header('Content-type: text/javascript'); /

    利用中国天气预报接口实现简单天气预报

    charset=utf-8”);$weather = file_get_contents&#40;“http://www.weather.com.cn/data/sk/101280601.html”&#41;;echo $weather;?&gt; 复制代码 代码如下:&lt;html&gt;&lt;head&gt;&lt;meta http-equiv=”Content...

    PHP连接数据库不完整

    php header("Content-type: text/html; charset=utf-8"); ?&gt; &lt;title&gt;php连接数据库&lt;/title&gt; &lt;link rel="stylesheet" href="./style/style.css"&gt; &lt;link rel="stylesheet" href="./style/...

    PHP实现即时输出、实时输出内容方法

    charset=utf-8″); #设置执行时间不限时 set_time_limit(0); #清除并关闭缓冲,输出到浏览器之前使用这个函数。 ob_end_clean(); #控制隐式缓冲泻出,默认off,打开时,对每个 print/echo 或者输出命令的结果都发送...

    图随窗口变化

    charset=utf-8" http-equiv="Content-Type"&gt;&lt;TITLE&gt;Ignite, full service interior and POS design &amp; build for retail brands | Ignite Retail&lt;/TITLE&gt; [removed][removed] [removed][removed...

    PHP 使用header函数设置HTTP头的示例解析 表头

    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...

    php+jquery编码方面的一些心得(utf-8 gb2312)

    复制代码 代码如下: //编码为gb2312,目前大部分网页还是用gb2312,少部分用utf-8, //www.baidu.com竟然两个都用,所以读取baidu的网页怎么搞都没问题 header(‘Content-Type: text/html; charset=gb2312’); //编码...

    PHP header()函数常用方法总结

    charset=utf-8 ‘);//Atom复制代码 代码如下:header(‘Content-type: application/atom+xml’);//CSS复制代码 代码如下:header(‘Content-type: text/css’);//Javascript复制代码 代码如下:header(‘Content-type: ...

    Java调用php的webservice

    charset=UTF-8"); // require('lib/nusoap.php'); require_once("lib/nusoap.php"); $server = new soap_server(); $server-&gt;configureWSDL('hellowsdl', 'urn:hellowsdl'); $server-&gt;wsdl-&gt;...

    PHP微信开发获取用户信息

    charset=utf-8"); //获取access_token开始 $appid = ""; $appsecret = ""; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret"; $ch = curl_...

    php中文乱码怎么办如何让浏览器自动识别utf-8

    charset=utf-8”); echo ‘我是初学者’; 不错需要注意的一点是 header(“Content-type: text/html; charset=utf-8”); 这一句前不能向页面输出任何内容,意思是不能使用echo等语句,也不能输出html标签或文字 您...

    完美解决PHP中文乱码

    一.... 如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312″),静态页面添加&lt;... 如果欲使用utf-8编码,那么php要输出头:header(“Content-Type: text/html; charset=u

    PHP 页面编码声明方法详解(header或meta)

    charset=utf-8”); php页面为gbk编码 header(“Content-type: text/html; charset=gb2312”); php页面为big5编码 header(“Content-type: text/html; charset=big5”); 通常情况以上代码放在php页面的首页 用header...

    两种设置php载入页面时编码的方法

    charset=utf-8″&gt;’; 2、在php页面或html页面&lt;meta http-equiv=”content-type” content=”text/html; charset=utf-8″&gt; 2:使用header函数 在控制器或页面里面header(“content-type:text/html; charset...

Global site tag (gtag.js) - Google Analytics