file_get_contents Time PHP

Asked

Viewed 64 times

-2

Guys the following I have a file_get_contents in php, but this API sometimes goes off the air and it takes a long time to answer, it would be like for a time limit if past this time returns an error.

Or any idea how to do this using Curl, I did so:

$url = "..../stations.json";

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL,$url);
        $response=curl_exec($ch);

        curl_close($ch);


        $response = json_decode($response);

1 answer

-2


set_time_limit('tempo-em-segundos');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.