Yogesh Chauhan's Blog

How to refresh a page using PHP at regularly occurring intervals?

in PHP on February 21, 2020

I use the following:


header("Refresh:0");

It refreshes the current page after some code executes(or not, your choice)

Also, if you need to redirect it to another page, we can add the target page as following:


header("Refresh:0; url=another_page.php");

It is not advisable to use it unless there is no other option as that 0 will continuously call server and update your local cache as well. If you use 3-4, it will refresh the page every 3-4 seconds.

Many times, if you want to use it with JavaScript alert, it doesn't work or the alert doesn't show up properly. Alternately, we can use JavaScript method as well, like:


location.reload()

The reload() method is used to reload the current document. The reload() method does the same as the reload button in your browser.


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
FULL OUTER JOIN in PostgresPostgresWhat are Stored Procedures for SQL Server?SQL/MySQLWhat is React? Learn the basicsReact2 Ways we can create an Array in JavaScriptJavaScriptHow to Write Complex Search Queries in SQL?SQL/MySQLHow does AdSense calculate page loading time?JavaScriptCreate a responsive image gallery using CSS gridCSSWhat is Zdog?MiscellaneousArbitrary Arguments in SCSS functionsSCSSHow to create a simple digital clock using JavaScript?JavaScriptWhat does JSX do in React?ReactAdvanced Array Methods in JavaScript (with examples)JavaScript