Working with header refresh using PHP

Now a days most of the website are providing real-time data streaming, when user visit the website they want to display the content without reloading the page, but how ?

there is a simple way to do it, we are going to create simple html with iframe tag which will call the server page to get the content every 5 seconds.

<html>
<head>
<title>Codeasearch.com - Tutorial - Working with header refresh using PHP</title>
</head>
<body>
<iframe src="server-page.php"></iframe>
</body>
</html>

Now our server page which will refresh every 5 seconds using header function in php, its will display date and time.

<?php
header("refresh:5;");
echo "Every 5 seconds iframe will refresh : ".date("Y-m-d H:i:s");
?>

 

Share