How to read HTTP and HTTPS (HTTP over SSL) web page with cURL in PHP

1 Answer

0 votes
function curl_get_url_contents($url)
{
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  $content = curl_exec($curl);
  curl_close($curl);
  
  return $content;
}


echo curl_get_url_contents("https://www.example.com/");

/*
run: 

<!doctype html>
<html>
<head>
    <title>Example Domain</title>
    ... 

*/

 



answered May 31, 2016 by avibootz

Related questions

1 answer 214 views
1 answer 255 views
2 answers 241 views
1 answer 164 views
...