欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

PHP sleep() 函數(shù)

定義和用法

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

seconds 必需。以秒計(jì)的暫停時(shí)間。
返回值

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

如果指定的描述 seconds 是負(fù)數(shù),該函數(shù)將生成一個(gè) 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 必需。以微秒計(jì)的暫停時(shí)間。
返回值

無返回值。
提示和注釋

注釋:在 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的用法

當(dāng)你需要程序暫停執(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ù)返回一個(gè)非0值。在windows平臺上,這個(gè)值總是192(這個(gè)值是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ù)為負(fù)值,則函數(shù)生產(chǎn)一個(gè)警告錯誤.

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

void usleep ( int $micro_seconds )

Delays program execution for the given number of micro seconds.

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

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

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

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

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

相關(guān)文章

最新評論