开发者

Which is faster? Using PHP's cUrl library or invoking curl utility form shell_exec()

开发者 https://www.devze.com 2023-03-15 15:51 出处:网络
For a PHP project i have to access RESTful API. I was using curl to get familiar with the API. I can access the开发者_StackOverflow said API using both PHP\'s cUrl library and invoking the curl utilit

For a PHP project i have to access RESTful API. I was using curl to get familiar with the API. I can access the开发者_StackOverflow said API using both PHP's cUrl library and invoking the curl utility using PHP's shell_exec() function. Performance wise, which option would be better and why??

PS: I have my own server with root privilege.


My cautious guess would be not too useful test snippets shows that the curl library is more performant.

Edit: A little test shows, that the library is faster, but not by much. Also, if you fetch millions of URLs, network latency will more likely be a bigger problem.


Performance is pretty much exactly the same, because the same stuff is being executed internally. But you should use the API because it is cleaner.

0

精彩评论

暂无评论...
验证码 换一张
取 消