PHP Auto Redirect: Set Page Timeout
In PHP, there are two ways to set a timeout for automatically closing pages:
- send a header in PHP
header("Refresh:5;url=closepage.php");
The above code will automatically redirect to the closepage.php page after 5 seconds on the current page.
- the location of the current web page
echo "<script>
setTimeout(function(){
window.location.href = 'closepage.php';
}, 5000); // 5 秒后自动跳转
</script>";
The code above will automatically redirect to the closepage.php page 5 seconds after the current page is opened.
Both of these methods will automatically close the current page after a certain amount of time.