PHP 字符串具有相同的编码 (UTF8) 并且在浏览器中显示为相同但不相等

PHP strings have same encoding (UTF8) and appear as identical in browser but are not equal

所以我需要与字符串进行比较(1 是 CURL 调用远程 URL 的结果,使用字符集 UTF8),另一个硬编码在我的脚本中(utf8 作为出色地)。 字符串看起来一样,但是当我使用 strcmp() 比较它们时,结果是 -44。 我尝试 trim() 两者,但结果仍然相同。

我仔细检查了他们的编码我们 mb_detect_encoding(),他们似乎都是 UTF8(正如我所期望的那样)。

我还用 preg_match('!!u', $string) 仔细检查它们,这似乎是检测它们是否也在 UTF8 中的准确方法。结果是 1,所以它们都是。

bin2hex(string1) hps://graph.facebook.com/v2.3/?id=hp://www.topito.com/top-images-monde-chats-connards-de-felins

68747470733a2f2f67726170682e66616365626f6f6b2e636f6d2f76322e332f3f69643d3c6c696e‌6b3e687474703a2f2f7777772e746f7069746f2e636f6d2f746f702d696d616765732d6d6f6e64652‌d63686174732d636f6e6e617264732d64652d66656c696e733c2f6c696e6b3e

bin2hex(string2) hps://graph.facebook.com/v2.3/?id=hp://www.topito.com/top-images-monde-chats-connards-de-felins

68747470733a2f2f67726170682e66616365626f6f6b2e636f6d2f76322e332f3f69643d68747470‌3a2f2f7777772e746f7069746f2e636f6d2f746f702d696d616765732d6d6f6e64652d63686174732‌​d636f6e6e617264732d64652d66656c696e73

如何使它们相等?我尝试使用 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 此处复制粘贴的源代码,它们并不相同。第二个字符串有一个额外的实体 & # 8203 ; (检查第二个`‌ ')

http://pasteboard.co/wBd2Ea4.png