PHP Refresh Vs. Meta Refresh

Discussion in 'PHP' started by Masterful, Nov 11, 2009.

  1. #1
    I'm using a PHP refresh. The code looks like this:

    <?php
    header("refresh: 10; url=some_url");
    ?>
    Code (markup):
    As you can see, it's set to refresh after 10 seconds.

    Questions:

    1. Does it refresh 10 seconds after the whole page has downloaded, including all images, or 10 seconds after the HTTP request?
    2. Are PHP refreshes more reliable and compatible than meta refreshes? Which one would you use if you had to do a refresh?
     
    Masterful, Nov 11, 2009 IP
  2. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    PHP refresh is executed from the server..
    Meta refresh executed from the browser..

    In php the function will be triggered when you call it..
    In meta it will be triggered after the whole page loaded..
     
    xenon2010, Nov 11, 2009 IP
    ShadyStudent likes this.
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    And a browser cant easily detect a php redirect if its done after a long time specially
     
    Bohra, Nov 12, 2009 IP
  4. Masterful

    Masterful Well-Known Member

    Messages:
    1,653
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #4
    I have put the PHP refresh right at the top of my document, above the doctype.

    Do you mean if it's called low in the page? But I thought PHP refreshes could only be put at the very top of the page, before any output to the client. Isn't that so?

    Thanks for the responses, guys, but can anyone answer my 2 questions?

    1. Does it refresh 10 seconds after the whole page has downloaded, including all images, or 10 seconds after the HTTP request?
    2. Are PHP refreshes more reliable and compatible than meta refreshes? Which one would you use if you had to do a refresh?
     
    Masterful, Nov 12, 2009 IP
  5. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #5
    1. It may depend on browser implementation. I think timer starts right after the whole page is loaded. Anyway you could measure this by yourself :)
    2. It seems header refresh and meta refresh act the same way, read more here.

    By the way, W3C lists META refresh as deprecated element.
     
    Last edited: Nov 12, 2009
    wmtips, Nov 12, 2009 IP
    Masterful likes this.
  6. Masterful

    Masterful Well-Known Member

    Messages:
    1,653
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #6
    One rep point. ;)

    Can anyone else answer the 2 questions?
     
    Masterful, Nov 13, 2009 IP