php乱码有关问题

WBOY
Release: 2016-06-13 13:39:29
Original
826 people have browsed it

php乱码问题
用php通过cmd命令执行了一个应用程序text.exe,本来应该显示“执行成功”,但是在cmd中能正常显示,在浏览器中却是乱码。php文件中meta标签已规定charset是utf-8,浏览器的字符编码也是utf-8.但要是把浏览器的字符编码改为GBK的话,“执行成功”这四个字倒是能正常显示,可是页面上的其他中文字符就成乱码了。该怎么处理呢?

------解决方案--------------------
文件编码也修改成utf-8格式.直接echo ('执行成功');
------解决方案--------------------
//说明你数据库中的是gbk编码的
数据库编码要与文件编码,浏览器编码一致就不会乱码了
现在可以在 mysql查询语句前加下这句 mysql_query("set names utf8")
------解决方案--------------------
如果‘执行成功’是取回的字符串而不是在脚本中自定义的字符串,那么用iconv转一下编码试试。
------解决方案--------------------
在文件最顶端输入:
header("Content-Type:text/html;charset=utf-8");
------解决方案--------------------
ob_start();
cmd命令执行了一个应用程序text.exe
$s = ob_get_clean();
echo iconv('gbk', 'utf-8', $s);

------解决方案--------------------
cmd好像默认就是用gbk编码的。 跟你的utf-8矛盾了。所以才会乱码。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!