网站验收,重庆网站建设费用,站长工具传媒,太原建设网站的公司安装了apache2.4.39以后#xff0c;默认编码是UTF-8#xff0c;不管你文件是什么编码#xff0c;统统按这个来解析#xff0c;因此 GB2312编码文件内的中文将显示为乱码。
!doctype html
html
headmeta http-equivContent-Type c…安装了apache2.4.39以后默认编码是UTF-8不管你文件是什么编码统统按这个来解析因此 GB2312编码文件内的中文将显示为乱码。
!doctype html
html
headmeta http-equivContent-Type contenttext/html;charsetGB2312 meta http-equivX-UA-Compatible contentIEedge,chrome1meta namerenderer contentwebkitmeta nameforce-rendering contentwebkitmeta nameviewport contentwidthdevice-width, user-scalableno, initial-scale1.0, maximum-scale1.0, minimum-scale1.0 / meta http-equivContent-Language contentzh-cn/headbody span中文测试/span hr/
?phpheader(Content-type:text/html;charsetGB2312);// $input_filed input typetext nameusername value.$_POST[username].;// echo $input_filed;$input_name input type text name username value .$_POST[username].;echo 请输入姓名 . $input_name;echo hr/;echo 中文测试;// //Example #1 $_POST 范例// echo Hello . htmlspecialchars($_POST[name]) . !;
?/body
/html 解决方案
打开apache配置文件 \Apachexxx\conf\httpd.conf ,查找AddDefaultCharset查看设置的是啥改为
AddDefaultCharset off
如果配置文件中没有AddDefaultCharset的话就加上一句
AddDefaultCharset off 改完了记得重启Apache 这样Apache就能按照文件中设定的编码来正确解析文件了前提是你的文件存储格式必须与设定编码一致。 如果不设置 AddDefaultCharset 那么新安装完Apache后默认都是用 UTF-8 编码来解析页面的。