Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,900 questions

51,831 answers

573 users

How to use curl_multi_getcontent() to get the content of a cURL handles in PHP

1 Answer

0 votes
$cui_1 = curl_init('https://collectivesolver.com/');
$cui_2 = curl_init('https://html.spec.whatwg.org/multipage/');
curl_setopt($cui_1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cui_2, CURLOPT_RETURNTRANSFER, true);
   
$cum = curl_multi_init();
curl_multi_add_handle($cum, $cui_1);
curl_multi_add_handle($cum, $cui_2);
   
$exe = null;
do {
    curl_multi_exec($cum, $exe);
 } while ($exe);
   
$content_1 = curl_multi_getcontent($cui_1);
$content_2 = curl_multi_getcontent($cui_2);
 
echo "-------------------------------------- content 1 ------------------------------ \n";
echo $content_1 . "\n\n";
echo "-------------------------------------- content 2 ------------------------------ \n";
echo $content_2;
 
 
 
 
 
 /*
 run:
 
-------------------------------------- content 1 ------------------------------ 
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>CollectiveSolver</title>
		<meta name="description" content="Programming Q&A in Java, Python, C, C++, C#, PHP, JavaScript, MySQL, WinAPI, Win32, VB.NET, SQL...
...

-------------------------------------- content 2 ------------------------------ 
<!DOCTYPE html><html class="split index" lang=en-US-x-hixie><script src=/link-fixup.js defer=""></script><meta charset=utf-8><meta content="width=device-width...
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
   function setLinkFragment(link) {
     link.hash = location.hash;
   }
  </script><body>
...

*/

 



answered Jun 8, 2016 by avibootz
edited Jan 11, 2023 by avibootz

Related questions

1 answer 241 views
1 answer 177 views
1 answer 272 views
272 views asked Jul 23, 2018 by avibootz
2 answers 1,008 views
...