YogeshChauhan . com

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.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

Revisiting variable scope in JavaScriptJavaScriptHow to create flickering text using CSS?CSSINNER JOIN in PostgresPostgresWhat is a “promise” in JavaScript?JavaScriptCheck if any column has NULL values in PostgresPostgresHow to create a flip effect with CSS?CSSHow to merge arrays in JavaScript?JavaScriptFor In Loop in Swift for BeginnersSwiftHow to remove border from :visited image, link or button?CSSClasses in JavaScript: The BasicsJavaScriptHow to create bouncing balls using HTML canvas and JavaScript?HTMLKilling A Project Part 2: Who should make the decision to kill a project?Misc