How to make a URL that updates every second without updating my page

Asked

Viewed 20 times

-1

Well I have a code in php, with an if and I would like if I could get the answer from Curl, only q this answer it updates every second so it is almost impossible if I get the answer like this, there is some way I can do with q if I get this answer without having to update the page?

    <?php

 $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://www.horario-brasilia.com/");
       $Horas = curl_exec($ch);

if (strpos($Horas, "10:00:00")) {
echo '10 horas';
}

?>
  • The best way to do this would be with javascript

1 answer

-1


PHP is interpreted before loading the page, for you to perform actions after loading you need a scripting language in the frontend, which does this checking every second.

In Javascript you can do using setInterval that runs a function every x milliseconds.

https://www.w3schools.com/jsref/met_win_setinterval.asp

Browser other questions tagged

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