How to refresh page in PHP?

by tressie.damore , in category: PHP General , 2 years ago

How to refresh page in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by darion , 2 years ago

@tressie.damore i believe you can use header() function to send the header to a browser and refresh the page in PHP, code:


1
2
3
4
<?php

// Refresh page in 1 sec
header("refresh: 1;");
by darrion.kuhn , 8 months ago

@tressie.damore 

In PHP, you can refresh the page using the header() function with the Location header. Here is an example:

1


In this example, the Refresh header is set to 0 seconds, which means the page will refresh instantly. If you want to specify a delay before the refresh, you can change the value to the desired number of seconds.


Note: The header() function needs to be called before any output is sent to the browser.