How can a delay be implemented in a PHP script before redirecting using the header function?
To implement a delay before redirecting using the header function in PHP, you can use the sleep function to pause the script execution for a specified amount of time before sending the header for redirection. This can be useful for scenarios where you want to display a message or perform some action before redirecting the user to another page.
<?php
// Delay for 3 seconds
sleep(3);
// Redirect to the desired page
header("Location: newpage.php");
exit();
?>
Keywords
Related Questions
- Are there any online resources or test versions available for practicing Oracle database interactions with PHP to troubleshoot issues like ORA-00000 and ORA-01002?
- How can string manipulation be effectively used in PHP to replace specific characters in a path or URL?
- How can one ensure that query results are displayed in alphabetical order when using PHP to query a MySQL database?