![]() The code below demonstrates the use of the usleep() function by delaying execution of the script by 1000000 μ s 1000000\mu s 1000000 μ s (1 second). For such durations, use the sleep() function instead. Note: When using usleep(), try not to set the delay to more than a second. Return valueīoth functions do not return any value, and the time delay may vary from machine to machine. Is it a good idea or should I use different delay ways sleep () keeps a connection open, could this be a problem I do: index.php -> stuff.php -> index. The sleep() and usleep() functions both accept a compulsory integer parameter, which is the delay duration in seconds and microseconds respectively. 1 Suppose a website with 'high' traffic, I want to use the php sleep (4) function to avoid flooding. The sleep() function will delay the script’s execution in seconds while usleep() will delay it in microseconds.īoth functions are supported by PHP 4 and later versions. You can prevent the problems of such conditions by delaying the script’s execution. It is most important to use these on scripts that start to execute after the system starts. With these functions, you can tell your script to basically pause script execution when they are encountered for a number of seconds or microseconds. Just as their names imply, these functions are used to delay code execution of scripts. Examples of such functions are the sleep() and usleep() functions. As you write these programs in PHP, you are equipped with many inbuilt functions that let you carry out a lot of manipulations off the shelf. Computer programs help us to control computing devices almost absolutely. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |