In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to implement a function in a few seconds". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Implementation method: 1, using the "sleep (delay seconds)" statement, you can delay the execution of the function for several seconds; 2, using the "time_nanosleep (delay seconds, delay nanosecond)" statement, you can delay the execution of the function for several seconds and nanoseconds; 3, using the "time_sleep_until (time () + 7)" statement.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
There are three functions in php that implement deferred execution:
Sleep () function
Time_nanosleep () function
Time_sleep_until () function
1. Use the sleep () function to delay the execution of a function
The sleep function indicates a delay in execution, which can delay the execution of the current script for several seconds. The syntax is:
Sleep ($seconds)
This function takes only one required argument, $seconds, which specifies how many seconds the script needs to delay. Returns 0 on success and FALSE; on error. If the call is interrupted by the signal, the function returns a non-zero value.
Let's take a look at this through a specific example:
Output result:
2. Use the time_nanosleep () function to delay the execution of a function
The time_nanosleep () function delays execution of the current script for several seconds and nanoseconds. The syntax is:
Time_nanosleep ($seconds,$nanoseconds)
This function takes two required arguments, $seconds (delay seconds) and $nanoseconds (delay nanoseconds). Returns 0 on success and FALSE; on error. If the call is interrupted by the signal, it returns an associative array with the number of seconds left in the delay and the number of nanoseconds remaining in the delay.
Let's take a look at this through a specific example:
Output result:
3. Use the time_sleep_until () function to delay the execution of the script
The time_sleep_until () function delays the execution of the current script until the specified time. The syntax is:
Time_sleep_until ($timestamp)
This function takes only one required argument, $timestamp, to specify the wake-up time. Returns 0 on success and FALSE on error.
Let's take a look at this through a specific example:
Output result:
This is the end of "how php implements a function in a few seconds". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.