How can I make a webpage automatically redirect after a certain amount of time in PHP?

To automatically redirect a webpage after a certain amount of time in PHP, you can use the header() function to set the "Location" header with the URL to redirect to. You can also use the sleep() function to delay the redirect for a specific amount of time before sending the header.

<?php
// Set the delay time in seconds
$delay = 5;

// Delay the redirect for the specified amount of time
sleep($delay);

// Redirect to the desired URL
header("Location: https://www.example.com");
exit;
?>