PHP hrtime() 函数
定义和用法
hrtime()
函数返回系统的高分辨率时间(high resolution time)。
这个时间通常用于性能测量,因为它提供了比常规时间函数(如 time())更高的精度。
实例
返回系统的高分辨率时间:
<html> <body> <?php echo hrtime(true), PHP_EOL; print_r(hrtime()); ?> </body> </html>
上述代码的输出可能会像这样:
749040731418900 Array ( [0] => 749040 [1] => 731419500 )
语法
hrtime(return_as_num)
参数 | 描述 |
---|---|
return_as_num |
可选。默认是 FALSE。 为 false 时,返回格式为 [seconds, nanoseconds] 整型数组。 为 true 时,返回奈秒( int (64 位平台)或 float (32 位平台))。 |
技术细节
返回值: | 返回纳秒或整数数组。 |
---|---|
PHP 版本: | 7.3+ |