国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

PHP sleep()函數, usleep()函數

2024-05-04 23:49:22
字體:
來源:轉載
供稿:網友

PHP sleep() 函數

定義和用法

sleep() 函數延遲代碼執行若干秒。
語法sleep(seconds)

seconds 必需。以秒計的暫停時間。
返回值

若成功,返回 0,否則返回 false。
錯誤/異常

如果指定的描述 seconds 是負數,該函數將生成一個 E_WARNING。

例子

<?php echo date('h:i:s') . "<br />"; //暫停 10 秒sleep(10);//重新開始 echo date('h:i:s'); ?>

 

輸出:

12:00:08 12:00:18


PHP usleep() 函數

定義和用法

usleep() 函數延遲代碼執行若干微秒。
語法usleep(microseconds)

microseconds 必需。以微秒計的暫停時間。
返回值

無返回值。
提示和注釋

注釋:在 PHP 5 之前,該函數無法工作于 Windows 系統上。

注釋:一微秒等于百萬分之一秒。
例子

<?php echo date('h:i:s') . "<br />"; //延遲 10 描述usleep(10000000);//再次開始 echo date('h:i:s'); ?>

 

輸出:
09:23:14 09:23:24

PHP中sleep和unsleep的用法

當你需要程序暫停執行幾秒可以用 sleep

int sleep ( int $seconds ) 程序暫停$seconds秒后執行。

Returns zero on success, or FALSE on error.成功返回0,錯誤返回false。

If the call was interrupted by a signal, sleep() 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.

如果調用被信號中斷,該函數返回一個非0值。在windows平臺上,這個值總是192(這個值是Windows API中等待IO完成WAIT_IO_COMPLETION的常量值)。其它平臺返回值為sleep還沒有執行的秒數。

If the specified number of seconds is negative, this function will generate a E_WARNING.

如果參數為負值,則函數生產一個警告錯誤.

當你需要程序暫停執行1秒一下時間的時候你可以用usleep

void usleep ( int $micro_seconds )

Delays program execution for the given number of micro seconds.

usleep參數是微秒,且無返回值。

當你需要程序執行單位更小(小于微秒)可以用

time_nanosleep() - Delay for a number of seconds and nanoseconds

如果你希望程序暫停執行到某個時間點,你可以用

time_sleep_until()- Make the script sleep until the specified time


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 夹江县| 合作市| 保亭| 阆中市| 乐山市| 九寨沟县| 海淀区| 自治县| 三亚市| 乌什县| 霍林郭勒市| 芜湖县| 广饶县| 巴彦县| 清远市| 蛟河市| 武鸣县| 繁昌县| 清苑县| 蒙自县| 永宁县| 西平县| 镇坪县| 潮州市| 拜泉县| 科尔| 马山县| 洪江市| 高陵县| 河津市| 杭州市| 湘西| 东乡族自治县| 惠州市| 合川市| 锡林浩特市| 枞阳县| 布拖县| 阜平县| 苏尼特左旗| 绥滨县|