PHP Redirect Pause

前端 未结 8 1206
北荒
北荒 2020-12-28 19:08

How do I pause a page for a certain amount of seconds before redirecting the user to another HTML/PHP page using PHP?

8条回答
  •  一生所求
    2020-12-28 19:49

    Low-tech solution requiring no Javascript or even PHP:

    
    
        Redirecting...
        
    
    
        You are being automatically redirected to a new location.
    If your browser does not redirect you in 10 seconds, or you do not wish to wait, click here.

    The advantage of this solution over using the "Location:" header is that you don't need to pause the script execution, which will appear to the user as if the server is busy or their connection has hung.

    This solution also gives the user the option of proceeding to the new page immediately rather than having to wait x number of seconds while their browser displays no information.

    Edit: I think it's also worth noting that if you do decide to use the the header() method, you need to make sure your sleep() duration isn't too long. I think most browsers generate a connection timed out after not receiving any data from the server for 1 minute.

提交回复
热议问题