In PHP, there is a sleep function, which presumably means that the program executes when it encounters the sleep function and pauses for n seconds after execution. As sleep (10) means that the program is executed from the top down, after encountering the sleep (10) statement pause 10 seconds, and then continue to execute
In some guessing site, if we need to do a timed execution function, such as a problem, in 10 seconds to complete, otherwise display "You have timed out", if completed, then jump to the next topic above, and this in the middle of a 10-second pause, such a function is how to achieve it?
In PHP, there is a sleep function, which presumably means that the program executes when it encounters the sleep function and pauses for n seconds after execution. As sleep (10) means that the program is executed from the top down, after encountering the sleep (10) statement pause for 10 seconds, and then continue to execute down. The argument within the parentheses of the function is a numeric value that represents the pause time, in seconds. Take a look at the following code:
<?php//Current Timeecho date (' H:i:s '). "\ n";//sleep for ten secondssleep;//Wake Up!echo date (' H:i:s '). "\ n";? >
The results of the above program execution are:
05:31:23
05:31:33
Some children's shoes may be the example of the time will say how my program execution error, prompt timeout. This problem does not panic, this is the default PHP page execution time caused by default in PHP execution page time is 30 seconds, which is sufficient for the general program. But if you want to do something like timed execution, you must then set the execution time Set_time_limit (0) in the head declaration. 0 is the representative of the time, the unit is the second.
If the execution time is more than 30 seconds, then do the operation remember to connect to MySQL again, or invalid execution!!! The reason is that the database connection may be disconnected after the execution time is too long, and the database information cannot be read!
To do it, add a paused feature to your instance, and then proceed down.
Summary: The above is the entire content of this article, I hope to be able to help you learn.