因此,我需要与字符串进行比较(1是使用字符集UTF8的CURL调用到远程URL的结果),另一个则是在我的脚本中进行硬编码的(以及utf8)。字符串看起来相同,但是当我使用strcmp()比较它们时,结果为-44。我试图修剪()他们两个,但仍然是相同的结果。
我用mb_detect_encoding()仔细检查了它们的编码,它们似乎都在UTF8中(正如我期望的那样)。
我还使用preg_match('!! u',$ string)仔细检查了它们,这似乎也是检测它们是否也为UTF8的准确方法。结果是1,所以两者都是。
bin2hex(string1) h ps://graph.facebook.com/v2.3/?id = h p://www.topito.com/top-images-monde-chats-connards-de-felins
68747470733a2f2f67726170682e66616365626f6f6b2e636f6d2f76322e332f3f69643d3c6c696e6b3e687474703a2f2f7777772e746f7069746f2e636f6d2f746f702d696d696c679e696e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6c6e6e6e6e6c6e6e6e6e6c6e6e6e6e6e6c6e6e6e6e6c6e6c6e6c6e6c6e6c6e6c6e6c6e6c6e6c6c6c6e6c6c6c6c6c6e6c6c6c6c6c6c5c人了
bin2hex(string2) h ps://graph.facebook.com/v2.3/?id = h p://www.topito.com/top-images-monde-chats-connards-de-felins
68747470733a2f2f67726170682e66616365626f6f6b2e636f6d2f76322e332f3f69643d687474703a2f2f7777772e746f7069746f2e636f6d2f74686f16702d6967f2e636f6d2f7463664732f2e636f6d2f7466536732f2e636f6d2f7466536732f2e636f6d2f7466546732f2e636f6d2f7466536732f2e636f6d2f7466536732f2e636f6f6f6b2e64646732f6d2f6f6b2e646732f
我怎样才能使他们平等?我试图使用mb_convert_encoding()将它们都转换为utf8(从utf8 ^^),但是它们仍然不相等...。
谢谢
编辑我正在使用cURL从此提要中提取我的字符串(即URL):h ** p://www.topito.com/feed
我的curl函数是:
$header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: timeout=5, max=100";
$header[] = "Accept-Charset: utf-8;q=0.7,*;q=0.7"; // Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "";
$curl = curl_init ();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($curl, CURLOPT_REFERER, "http://www.google.fr");
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, getcwd().'/cookies.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, getcwd().'/cookies.txt');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($curl);
curl_close ( $curl );
如果您查看粘贴在此处的内容的HTML源代码,则它们是不同的。第二个字符串还有一个附加实体​ (检查第二个``'')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句