我正在使用 Solr,并且在我的浏览器中可以正常使用以下查询:
http://www.someipaddress.com:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:"Bausch+%26+Lomb"
在返回 xml 的一部分中,我看到:
<str>manufacturer:"Bausch & Lomb"</str>
但是,当我尝试使用 simplexml_load_file 获取上述 url 时,如下所示:
$xml = simplexml_load_file("http://127.0.0.1:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:\"Bausch+%26+Lomb\"");
我没有得到任何结果,因为 Solr 正在传递看起来像这样的制造商字符串(来自 print_r):
[str] => Array ( [0] => shopid:40 [1] => manufacturer:"Bausch+%26+Lomb" )
因此,当我通过浏览器进行查询时,我传入 %26 但它在查询中正确处理它。但是当我使用 simplexml_load_file 时,它仍然为 %26,因此查询失败。