函数名称:microtime()
函数说明:microtime()函数返回当前 Unix 时间戳和微秒数的字符串表示。
适用版本:PHP 4, PHP 5, PHP 7
语法:microtime(bool $get_as_float = false) : string|float
参数:
返回值:
示例1(返回字符串形式的时间戳):
$start = microtime();
// 执行一些代码
$end = microtime();
$timeTaken = $end - $start;
echo "执行时间:" . $timeTaken . " 秒";
示例2(返回浮点数形式的时间戳):
$start = microtime(true);
// 执行一些代码
$end = microtime(true);
$timeTaken = $end - $start;
echo "执行时间:" . $timeTaken . " 秒";
注意事项: