<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CURL on seth-shi</title><link>https://sethix.com/tags/curl/</link><description>Recent content in CURL on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 17 Jun 2020 15:04:16 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/curl/index.xml" rel="self" type="application/rss+xml"/><item><title>Making Concurrent Requests in PHP</title><link>https://sethix.com/posts/2020061715/</link><pubDate>Wed, 17 Jun 2020 15:04:16 +0800</pubDate><guid>https://sethix.com/posts/2020061715/</guid><description>PHP has always operated with a page-level lifecycle, where variables from previous requests aren&amp;rsquo;t shared with subsequent ones (unlike resident memory languages).
Most PHP code executes sequentially from top to bottom without callback capabilities The curl_multi_* function family enables &amp;ldquo;multi-threaded&amp;rdquo;-like behavior in PHP Recommended library for easier implementation: https://github.com/php-curl-class/php-curl-class Official concurrent request demo
&amp;lt;?php require __DIR__ . &amp;#39;/../vendor/autoload.php&amp;#39;; use Curl\MultiCurl; $urls = array( &amp;#39;tag3&amp;#39; =&amp;gt; &amp;#39;https://httpbin.org/post&amp;#39;, &amp;#39;tag4&amp;#39; =&amp;gt; &amp;#39;https://httpbin.org/get&amp;#39;, &amp;#39;tag5&amp;#39; =&amp;gt; &amp;#39;https://httpbin.</description></item></channel></rss>