Get file content from a URL?

Get file content from a URL?

$jsonData = json_decode(file_get_contents(',40&chl=Hello|World&chof=json'));
However, if allow_url_fopen isn't enabled on your system, you could read the data via CURL as follows:

By using curl method::

$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, ',40&chl=Hello|World&chof=json');

curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);

$jsonData = json_decode(curl_exec($curlSession));

Leave a Reply

Your email address will not be published. Required fields are marked *