In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use PHP to treat continuous records within N seconds as a record". 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!
It's interesting: PHP regards continuous records within N seconds as a record.
Now it's 11:34:00 seconds, and I'm sending a "hello," to the system.
02 seconds-"I" 03 seconds-"am" 04 seconds-"php_yt"
When sending "hello", the system saves a record
Sendtime:1638589060,text:hello
Within 5 seconds, the system is treated as a record, that is,
Sendtime:1638589060,text:hello, i am php_yt
It can be implemented through the following
$now = time (); $now2 = intval ($now / 5) * 5
Test code
Echo $now = time (); / / 1638589533echo PHP_EOL;echo $now / 5 intval / 327717906.6echo PHP_EOL;echo $custom_time = intval ($now / 5) * 5 Tring hand 1638589530
If hello, the time of this record is 1638589530, then the current timestamp 1638589533 is also regarded as the same time as hello.
Of course, it can also be adjusted from 5 seconds to 10 seconds, and the principle is
Echo $now / 5; / / 327717906.6 forward 0.2 decimal point per second, rounded and ignored
For 10 seconds, the decimal point is forward 0.1, rounded and ignored.
However, the above has bug, which can convert the sending time over a period of time to custom_time merging.
This is the end of the content of "how to use PHP to treat continuous records within N seconds as a record". 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.