Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Php Sleep Function

The sleep function does not work as I expect



8:58 pm on Apr 4, 2008 (gmt 0)

10+ Year Member


I have a list of users and I want to display each one ONE SECOND after the last.

So I use the sleep() function, and what happend is, that it sleep the total amount of all records and then displays all of them of a sudden.

Ej. If I have 20 users, the sistem last 20 seconds and show all of them suddenly, no one by one.



9:05 pm on Apr 4, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

PHP doesn't send anything to the browser until the script has completed its execution. You'd have to use a browser-side script like Javascript to do what you want.


7:27 pm on Apr 5, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

or you can flush [php.net] the information upon each iteration after the sleep().


11:13 pm on Apr 7, 2008 (gmt 0)

10+ Year Member

Thank you coopster, the flush() worked fine.

Featured Threads

Hot Threads This Week

Hot Threads This Month