函数文档

timer_float()

💡 云策文档标注

概述

timer_float() 是一个 WordPress 函数,用于获取当前 PHP 脚本执行至今的已用时间。它返回一个浮点数,表示从脚本启动开始的秒数。

关键要点

  • timer_float() 返回自 PHP 脚本启动以来的秒数,以浮点数形式表示。
  • 该函数基于 microtime(true) 和 $_SERVER['REQUEST_TIME_FLOAT'] 计算时间差。
  • timer_float() 在 WordPress 5.8.0 版本中引入。

代码示例

function timer_float() {
	return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'];
}

📄 原文内容

Gets the time elapsed so far during this PHP script.

Return

float Seconds since the PHP script started.

Source

function timer_float() {
	return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'];
}

Changelog

Version Description
5.8.0 Introduced.