I'm having problem with CURL from a link. I'm able to get an output with file_get_contents(); But having problems with CURL
use json_decode I get a NULL with cURL, but with file_get_contents() I get an Array
Using cURL
$url="https://example.com/"
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json= json_decode(curl_exec($ch),true);
echo $json; //outputs NULL
Using file_get_contents();
$json_pi = file_get_contents($url);
echo json_decode($json_pi,true);
Can anyone help me understand cURL? And why I might be getting these two conflicting results?
Thank you!