Home > Backend Development > PHP Tutorial > Does JavaScript have a delay function? Does PHP have one?

Does JavaScript have a delay function? Does PHP have one?

WBOY
Release: 2016-07-06 13:52:41
Original
1003 people have browsed it

It’s vb’s Sleep 100
c’s delay
means waiting for 100 milliseconds..

Reply content:

It’s vb’s Sleep 100
c’s delay
means waiting for 100 milliseconds..

<code>#js
settimeout("test()","2000");  //2000毫秒后执行test()函数,只执行一次。
setinterval("test()","2000"); //每隔2000毫秒执行一次test()函数,执行无数次。
#php
sleep() - 延缓执行
usleep() - 以指定的微秒数延迟执行</code>
Copy after login

js

<code>  setTimeout(function(){},1000)</code>
Copy after login

php

<code>sleep(10);</code>
Copy after login

jsThere is no delay function equivalent to what you said sleep/delay. Strictly speaking, except for delay, these two functions will 阻塞current thread, wait for delay过了之后 Then continue to execute the following code

The setTimeout and setInterval answered by LS are both 不阻塞 for the current thread. They just set a timer in the background. After the setting is completed, the code after 立马继续执行 will be executed after the timer time is up. Corresponding code

php Use sleep/usleep, the effect is the same as c

php uses sleep(1); wait for 1 second

I looked through the poster’s question record and advised him to give up this industry as soon as possible.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template