Home >Backend Development >PHP Tutorial >运用fsockopen函数返回的里面有中文显示乱码

运用fsockopen函数返回的里面有中文显示乱码

WBOY
WBOYOriginal
2016-06-13 10:36:171422browse

使用fsockopen函数返回的里面有中文显示乱码
程序:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->            $domain = "6zhou.com";            $whois_server = "whois.ename.com";            $data = "";            $fp = fsockopen($whois_server, 43, $errNo, $errStr, 55);            if($fp)            {                fputs($fp, $domain. "\r\n");                while (!feof($fp)) {                    $data .= fgets($fp, 128);                }                fclose($fp);                $data = nl2br(htmlentities($data));                echo $data;            }


运行结果显示:
Assembly code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Domain Name : 6zhou.comRegistrant : é?middot;æµ·å?micro;Domain Name Server : dns1.iidns.comdns2.iidns.comdns3.iidns.comdns4.iidns.comdns5.iidns.comdns6.iidns.comæ?yen;ç湅å®?aelig;?acute;whois请å?deg;:http://whois.ename.net/6zhou.comFor more information,please go to: http://whois.ename.net/6zhou.com


注意里面有乱码字符,像这种情况应该怎么处理让它显示正常?

浏览器不管是使用utf8或gbk显示都没用

------解决方案--------------------
去掉 htmlentities 
或者给 htmlentities 指定合适的字符集名称
Statement:
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