I would like to know how I can make this
index.php
<?php
echo "Players Online: ".$Hypixel->players->online."/".$Hypixel->players->max."<br />";
?>
is being updated every 5 seconds
servers.php
<?php
$Hypixel_json_infoquery = file_get_contents('https://use.gameapis.net/mc/query/info/mc.hypixel.net');
$Hypixel = json_decode($Hypixel_json_infoquery);
?>
PHP only updates on page load. It can be forced to do a meta refresh, but that would cause a full reload.
Your best bet is to write some JavaScript that does an Ajax request, and updates the page DOM. Something similar to this should work (in all browsers bar IE11):
setInterval(function () { fetch('https://use.gameapis.net/mc/query/info/mc.hypixel.net') .then(function(response) { // update DOM here }); }, 5)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.