【发布时间】:2015-01-19 03:42:00
【问题描述】:
我注意到 curl 比 file_get_contents 快很多,还有什么更快的吗?
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,'http://api.blah.com/xml.php');
$content = curl_exec($ch);
$xml = new SimpleXMLElement($content);
$file = file_get_contents('http://api.blah.com/xml.php');
$xml = new SimpleXMLElement($file);
现在还有很多其他类似的问题,但没有一个能回答主要问题,是否有更快的测试替代方案?没有其他人提供此答案,有些人提到了套接字,但没有人提供比较测试速度。
【问题讨论】:
-
如果 curl 比
file_get_contents快很多,你应该检查你的服务器配置,因为通常情况下不应该这样。
标签: php xml curl file-get-contents