最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2016年08月25日 12:51:27   投稿:mdxy-dxy  
這篇文章主要介紹了PHP sleep()函數(shù), usleep()函數(shù),需要的朋友可以參考下

PHP sleep() 函數(shù)

定義和用法

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

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

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

如果指定的描述 seconds 是負數(shù),該函數(shù)將生成一個 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() 函數(shù)

定義和用法

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

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

無返回值。
提示和注釋

注釋:在 PHP 5 之前,該函數(shù)無法工作于 Windows 系統(tǒng)上。

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

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

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

PHP中sleep和unsleep的用法

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

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

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.

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

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

如果參數(shù)為負值,則函數(shù)生產(chǎn)一個警告錯誤.

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

void usleep ( int $micro_seconds )

Delays program execution for the given number of micro seconds.

usleep參數(shù)是微秒,且無返回值。

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

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

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

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

相關(guān)文章

最新評論

江西省| 永州市| 天津市| 壤塘县| 南部县| 博爱县| 泗阳县| 临夏县| 桃园市| 怀宁县| 云龙县| 澄江县| 固始县| 外汇| 阿拉善左旗| 建宁县| 丹东市| 顺平县| 封丘县| 洱源县| 南平市| 龙岩市| 沈阳市| 杭锦后旗| 张家港市| 台州市| 洞头县| 石嘴山市| 原平市| 天柱县| 朝阳县| 清涧县| 沂源县| 新沂市| 桦川县| 玛多县| 定结县| 九江县| 两当县| 深州市| 防城港市|