How to Refresh the Page After 3 SEC in PHP

When designing a website, you might find a need to force a page to refresh; for instance, if you have a constantly updated stream of information such as a Twitter feed or you want to redirect visitors to another page while you redesign the current one. The PHP header function sends a raw HTTP header to a client browser. Use this function and provide the "refresh" and "URL" attributes to tell the browser how long to wait before refreshing and what page to load afterward.

Instructions

    • 1

      Open the HTML file. Place the cursor at the top of the body element.

    • 2

      Type the following:

      <?php

      header( "refresh: 3; URL=/filename.html" );

      echo "This page will refresh in 3 seconds.";

      ?>

      These lines open a PHP tag and use the header function to refresh the page. Unlike some other PHP functions that use milliseconds, the "refresh" attribute uses seconds. You may change this number as needed. The "URL" attribute tells the browser which page to load after the time expires. Change this value to the file name that contains these lines or type a different URL to redirect the visitor to a different page.

    • 3

      Save and close the HTML file.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured