How can you delay a page redirect using PHP's header function?
When using PHP's header function to redirect a page, you can delay the redirect by using the sleep function before sending the header. This can be useful in situations where you want to display a message to the user before redirecting them to another page.
<?php
// Delay the redirect by 3 seconds
sleep(3);
header("Location: newpage.php");
exit;
?>
Keywords
Related Questions
- How can PHP be used to implement a messaging system within a website without using email?
- What is the significance of the error message "Warning: preg_match() expects parameter 2 to be string, resource given" in PHP?
- What are the drawbacks of using IP address or session ID as unique fields in PHP to prevent duplicate database entries?