<small id='SK4uU'></small><noframes id='SK4uU'>

<tfoot id='SK4uU'></tfoot>

        <bdo id='SK4uU'></bdo><ul id='SK4uU'></ul>
      <i id='SK4uU'><tr id='SK4uU'><dt id='SK4uU'><q id='SK4uU'><span id='SK4uU'><b id='SK4uU'><form id='SK4uU'><ins id='SK4uU'></ins><ul id='SK4uU'></ul><sub id='SK4uU'></sub></form><legend id='SK4uU'></legend><bdo id='SK4uU'><pre id='SK4uU'><center id='SK4uU'></center></pre></bdo></b><th id='SK4uU'></th></span></q></dt></tr></i><div id='SK4uU'><tfoot id='SK4uU'></tfoot><dl id='SK4uU'><fieldset id='SK4uU'></fieldset></dl></div>

      <legend id='SK4uU'><style id='SK4uU'><dir id='SK4uU'><q id='SK4uU'></q></dir></style></legend>

      PHP Curl UTF-8 字符集

      时间:2023-10-03

      1. <legend id='awCpn'><style id='awCpn'><dir id='awCpn'><q id='awCpn'></q></dir></style></legend>
        <tfoot id='awCpn'></tfoot>
          <tbody id='awCpn'></tbody>
              • <bdo id='awCpn'></bdo><ul id='awCpn'></ul>
              • <i id='awCpn'><tr id='awCpn'><dt id='awCpn'><q id='awCpn'><span id='awCpn'><b id='awCpn'><form id='awCpn'><ins id='awCpn'></ins><ul id='awCpn'></ul><sub id='awCpn'></sub></form><legend id='awCpn'></legend><bdo id='awCpn'><pre id='awCpn'><center id='awCpn'></center></pre></bdo></b><th id='awCpn'></th></span></q></dt></tr></i><div id='awCpn'><tfoot id='awCpn'></tfoot><dl id='awCpn'><fieldset id='awCpn'></fieldset></dl></div>

              • <small id='awCpn'></small><noframes id='awCpn'>

                本文介绍了PHP Curl UTF-8 字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个 php 脚本,它调用另一个网页并写入页面的所有 html,一切正常,但是存在字符集问题.我的 php 文件编码是 utf-8 并且所有其他 php 文件都可以正常工作(这意味着服务器没有问题).该代码中缺少什么,所有西班牙语字母看起来都很奇怪.附注.当我将这些奇怪的字符原始版本写入php时,它们看起来都很准确.

                I have an php script which calls another web page and writes all the html of the page and everything goes ok however there is a charset problem. My php file encoding is utf-8 and all other php files work ok (that means there is no problem with server). What is the missing thing in that code and all spanish letters look weird. PS. When I wrote these weird characters original versions into php, they all look accurate.

                header("Content-Type: text/html; charset=utf-8");
                function file_get_contents_curl($url)
                {
                    $ch=curl_init();
                    curl_setopt($ch,CURLOPT_HEADER,0);
                    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
                    curl_setopt($ch,CURLOPT_URL,$url);
                    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
                    $data=curl_exec($ch);
                    curl_close($ch);
                    return $data;
                }
                $html=file_get_contents_curl($_GET["u"]);
                $doc=new DOMDocument();
                @$doc->loadHTML($html);
                

                推荐答案

                简单:当您使用 curl 时,它会将字符串编码为 utf-8 您只需要解码它们..

                Simple: When you use curl it encodes the string to utf-8 you just need to decode them..

                Description
                
                string utf8_decode ( string $data )
                

                此函数将假定为 UTF-8 编码的数据解码为 ISO-8859-1.

                This function decodes data , assumed to be UTF-8 encoded, to ISO-8859-1.

                这篇关于PHP Curl UTF-8 字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:将重音字符转换为它们的纯 ascii 等价物 下一篇:UTF-8 问题 PHP/MySQL

                相关文章

                最新文章

              • <small id='E2Qve'></small><noframes id='E2Qve'>

                  1. <tfoot id='E2Qve'></tfoot>

                    • <bdo id='E2Qve'></bdo><ul id='E2Qve'></ul>

                  2. <i id='E2Qve'><tr id='E2Qve'><dt id='E2Qve'><q id='E2Qve'><span id='E2Qve'><b id='E2Qve'><form id='E2Qve'><ins id='E2Qve'></ins><ul id='E2Qve'></ul><sub id='E2Qve'></sub></form><legend id='E2Qve'></legend><bdo id='E2Qve'><pre id='E2Qve'><center id='E2Qve'></center></pre></bdo></b><th id='E2Qve'></th></span></q></dt></tr></i><div id='E2Qve'><tfoot id='E2Qve'></tfoot><dl id='E2Qve'><fieldset id='E2Qve'></fieldset></dl></div>
                    <legend id='E2Qve'><style id='E2Qve'><dir id='E2Qve'><q id='E2Qve'></q></dir></style></legend>