PHP용 경과시간 체크함수 /php timer 타이머/ microtime()

<?
function php_timer(){
  static $arr_timer;
  if(!isset($arr_timer)){
  $arr_timer = explode(" ", microtime());
  }else{
    $arr_timer2 = explode(" ", microtime());
    $result = ($arr_timer2[1] - $arr_timer[1]) + ($arr_timer2[0] - $arr_timer[0]);
    $result = sprintf("%.4f",$result);
    return $result;
  }
  return false;
}
?>
<?
//----------------------------예제

print("초기화");
print php_timer().'<br>';
print("2초 쉽니다.");
sleep(2);
print php_timer().'<br>';
print("3초 쉽니다.");
sleep(3);
print php_timer().'<br>';
print("4초 쉽니다.");
sleep(4);
print php_timer().'<br>';
?>

댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
목록형 📷 갤러리형
제목
[기본형] HTML (with 부트스트랩5.3 , jquery 3.7, vue.js)
유용한 리눅스(LINUX) 명령어
[공지] 기술 게시판
6.29
6.30
7.1
7.2
7.3
7.4
7.5
7.6
7.7
7.8
7.9
7.10
7.11
7.12
7.13
7.14
7.15
7.16
7.17
7.18
7.19
7.20
7.21
7.22
7.23
7.24
7.25
7.26
7.27
7.28
7.29
7.30
7.31
8.1
8.2