: How to make a program that display something and after 10 seconds automatically redirect to another site? <?php echo "Hello World"; sleep(10); header("Location: " . "http://google.com");
<?php
echo "Hello World";
sleep(10);
header("Location: " . "http://google.com");
?>
The problem with this is that header is already sent
Warning: Cannot modify header information - headers already sent by (output started at /home2/provenda/public_html/silverslady.com/index.php:46) in /home2/provenda/public_html/silverslady.com/index.php on line 75
More posts by @Holmes151
2 Comments
Sorted by latest first Latest Oldest Best
Here is 2 ways to do this:
<?php
echo '<meta http-equiv="refresh" content="10; url=http://example.com/">';
?>
or
<?php
header("refresh:10;url=http://example.com");
?>
I'd recommend the second option.
About the "headers already sent"-error. That is commonly know as "the whitespace problem". Here is an exceptionally good response concerning the subject: stackoverflow.com/a/8028987/668236
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.