php curl get contents of url

Solutions on MaxInterview for php curl get contents of url by the best coders in the world

showing results for - "php curl get contents of url"
Magdalena
05 Jan 2018
1<?php
2
3// Get the contents of a URL
4function curl_get_contents($url): string
5{
6    $ch = curl_init();
7    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
8    curl_setopt($ch, CURLOPT_HEADER, FALSE);
9    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
10    curl_setopt($ch, CURLOPT_URL, $url);
11    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
12    curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
13    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
14    $response = curl_exec($ch);
15    curl_close($ch);
16    return $response;
17}