time_nanosleep — 수초 및 나노 초 동안 지연 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

time_nanosleep — 수초 및 나노 초 동안 지연 정보

PHP time_nanosleep — 수초 및 나노 초 동안 지연

본문

time_nanosleep — 수초 및 나노 초 동안 지연

 

설명 ¶

 

mixed time_nanosleep ( int $seconds , int $nanoseconds )

 

지정된 초 수 및 나노초 동안 프로그램 실행을 지연합니다.

 

인수 ¶

 

seconds

음수가 아닌 정수 여야합니다.

 

nanoseconds

10 억 미만의 음수가 아닌 정수 여야합니다.

 

반환값 ¶

 

성공 시 TRUE를, 실패 시 FALSE를 반환합니다.

 

 

지연이 신호에 의해 인터럽트되면 연관 배열이 다음 구성 요소와 함께 반환됩니다.

 

seconds - 지연 시간 (초)

nanoseconds - 지연 내에 남아있는 나노초의 수

 

Example #1 time_nanosleep() example

 

<?php

 

// 조심해! 배열이 반환되면 예상대로 작동하지 않습니다.

 

if (time_nanosleep(0, 500000000)) {

    echo "Slept for half a second.\n";

}

 

// This is better:

if (time_nanosleep(0, 500000000) === true) {

    echo "Slept for half a second.\n";

}

 

// And this is the best:

$nano = time_nanosleep(2, 100000);

 

if ($nano === true) {

    echo "Slept for 2 seconds, 100 microseconds.\n";

} elseif ($nano === false) {

    echo "Sleeping failed.\n";

} elseif (is_array($nano)) {

    $seconds = $nano['seconds'];

    $nanoseconds = $nano['nanoseconds'];

    echo "Interrupted by a signal.\n";

    echo "Time remaining: $seconds seconds, $nanoseconds nanoseconds.";

}

?>

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로