❮ Php TÀI LIỆU THAM KHẢO
Thí dụ
Trì hoãn thực thi tập lệnh hiện tại trong 3 giây:
echo date['h:i:s'];
?>
Hãy tự mình thử »
Định nghĩa và cách sử dụng
Hàm giấc ngủ [] trì hoãn việc thực thi tập lệnh hiện tại trong một số giây được chỉ định.
Lưu ý: Hàm này ném lỗi nếu số giây được chỉ định là âm. This function throws an error if the specified number of seconds is negative.
Cú pháp
Giá trị tham số
giây | Yêu cầu. Chỉ định số giây để trì hoãn tập lệnh |
Chi tiết kỹ thuật
Trả về 0 khi thành công, hoặc sai về lỗi. Hàm này trả về một giá trị khác không nếu cuộc gọi bị gián đoạn bởi tín hiệu. Trên Windows, giá trị này sẽ luôn là 192, là giá trị của hằng số WAIT_IO_COMPLETER trong API Windows. Trên các nền tảng khác, giá trị trả về sẽ là số giây còn lại để ngủ.192, which is the value of the WAIT_IO_COMPLETION constant within the Windows API. On other platforms, the return value will be the number of seconds left to sleep. |
4+ |
Trước Php 5.3.4, chức năng này luôn trả về NULL khi giấc ngủ xảy ra trên Windows. |
❮ Php TÀI LIỆU THAM KHẢO
Jimmy tại Powerzone Dot DK ¶
12 năm trước — Delay execution
13 năm trước
manu7772 tại gmail dot com ¶[int $seconds
]: int
f dot schima tại ccgmbh dot de ¶
toddjt78 tại msn dot com ¶:
mã {@} Ashleyhunt [dot] co [dot] uk ¶usleep[] as the sleep[] function expects an int. For example,
sleep[0.25]
will pause program execution for0
seconds.
SoulHunter1987 tại Post Dot Ru ¶
smcbride tại msn dot com ¶Webseos tại Gmail Dot Com ¶
14 năm trước
Mohd tại Bahrain dot bz ¶
WAIT_IO_COMPLETION
3sleep[] returns a non-zero value. On Windows, this value will always be 192
[the value of the WAIT_IO_COMPLETION
constant within the Windows API]. On other platforms, the return value will be the number of seconds left to sleep.
Errors/Exceptions
Việc sử dụng giấc ngủ trong PHP là gì?ValueError.
Hàm giấc ngủ [] trì hoãn việc thực thi tập lệnh hiện tại trong một số giây được chỉ định. Lưu ý: Hàm này ném lỗi nếu số giây được chỉ định là âm.
8.0.0 | Hàm ném một giá trị horror trên âm seconds ; Trước đây, một seconds 0 đã được nâng lên thay vào đó và chức năng đã trả lại seconds 1.ValueError on negative seconds ; previously, an seconds 0 was raised instead, and the function returned seconds 1.
|
Ví dụ
Ví dụ #1 Sleep [] Ví dụsleep[] example
seconds
2
Ví dụ này sẽ xuất ra [sau 10 giây]
Xem thêm
- usleep [] - Thực hiện trì hoãn trong micro giây
- time_nanos ngủ [] - trễ trong một số giây và nano giây
- time_sleep_until [] - Làm cho tập lệnh ngủ cho đến khi thời gian quy định
- set_time_limit [] - giới hạn thời gian thực hiện tối đa
Ash b ¶ ¶
8 năm trước
seconds
3
seconds
4
seconds
5Ẩn danh ¶ ¶
4 năm trước
seconds
6
Barlow tại fhtsolutions dot com ¶
11 năm trước
seconds
7
MPHH ¶ ¶
19 năm trước
seconds
8
Diego Andrade ¶ ¶
6 năm trước
seconds
9
sleep[0.25]
0
seconds
5Hartmut lúc sáu chấm de ¶ ¶
22 năm trước
sleep[0.25]
2
sleep[0.25]
3
sleep[0.25]
4
sleep[0.25]
5
sleep[0.25]
6
seconds
5Ẩn danh ¶ ¶
8 năm trước
sleep[0.25]
8
sleep[0.25]
9
seconds
5
seconds
5 ¶
Ẩn danh ¶
0
1
Ẩn danh ¶ ¶
1 năm trước
0
2
0
3
0
4
0
5LVT ¶ ¶
9 năm trước
0
6
Joshmeister tại Gmail Dot Com ¶ ¶
10 năm trước
0
7
Jimmy tại Powerzone Dot DK ¶ ¶
12 năm trước
0
8
0
9
seconds
0
seconds
1
seconds
5Ẩn danh ¶ ¶
13 năm trước
seconds
3
seconds
4
seconds
5
manu7772 tại gmail dot com ¶ ¶
1 năm trước
seconds
6
seconds
7
seconds
5LVT ¶ ¶
12 năm trước
seconds
9
13 năm trước ¶
12 năm trước
0
0
0
1
manu7772 tại gmail dot com ¶ ¶
f dot schima tại ccgmbh dot de ¶
0
3
0
4
0
5
0
6
0
7
seconds
5LVT ¶ ¶
9 năm trước
0
9
0
6 ¶
12 năm trước
192
0
192
1
seconds
5
13 năm trước ¶
1 năm trước
192
3
192
4
seconds
5manu7772 tại gmail dot com ¶ ¶
f dot schima tại ccgmbh dot de ¶
192
6
192
7
192
8
seconds
5toddjt78 tại msn dot com ¶ ¶
12 năm trước
WAIT_IO_COMPLETION
0
WAIT_IO_COMPLETION
1
WAIT_IO_COMPLETION
2