Jump to content

Sleep func problem


ylkien

Recommended Posts

Hi guys,

I am trying to create a simple script to display some messages, wait, then forwarding it to another page. The problem I have is that it won't display anything if I use the function "sleep". This means, it will straightway goto the redirected page w/o displaying any message...

It will display the message if I use "ob_flush" & "flush", but when trying to redirect it, the error "...headers already sent by..." comes out.

Below is a snipper of the code :

[code]function Transfer_Back( $Sleep_Time )
{

        echo "Hello";
ob_flush();
flush();

Sleep( $Sleep_Time );

Header("Location:http://localhost");
}
[/code]
Link to comment
Share on other sites

If you want to output stuff before redirecting, you could use the 'refresh' meta tag in the <head> section of your html

[code]
<meta http-equiv="Refresh" content="3;URL=http://localhost">
[/code]

will redirect the browser to 'http://localhost' after 3 seconds.

Hope that helps!  BTW, using meta refresh won't go down well with some accessibility validators, as it's a bunch of no fun for speech screen readers.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.