Php microtime() 无法在实时站点上运行。寻找解决方法

Php microtime() is not working on live site. Looking for workaround

我在 Windows 上安装了 Zend Server 6.3 和 Php 5.4。系统运行良好。现在我将代码移至实时站点,该站点使用 DirectAdmin 在 Ubuntu 服务器上运行 Php 5.3.29。所有其他网站都 运行 在那里。但是我当前的网站给了我这个错误(该网站在 WordPress 4.3 上):

Warning: mysql_connect(): Headers and client library minor version mismatch.
Headers:50541 Library:50623 in /home/cheapauto/domains/*DOMAIN*/public_html/wp-includes/wp-db.php on line 1482
Parse error: syntax error, unexpected '[' in /home/*USER*/domains/*DOMAIN*/public_html/wp-content/plugins/*MY-PLUGIN*/includes/final.class.NRSBooking.php on line 101 

行是这样的:

$now = explode(' ', microtime())[1];

我的整个插件功能是这样的:

private function getIncrementalHash($length = 5)
{
    //$charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    $charset = "ABCDEFGHIJKLMNPRSTUVYZ"; // fits LT & EN, O is skipped to similarity to Zero
    $charsetLength = strlen($charset);
    $result = '';

    $now = explode(' ', microtime())[1];
    while ($now >= $charsetLength)
    {
        $i = $now % $charsetLength;
        $result = $charset[$i] . $result;
        $now /= $charsetLength;
    }
    return substr($result, -$length);
}

有什么想法可以让它在实时站点上运行吗?

根据 Php 参考 http://php.net/manual/en/function.microtime.php 它说:

microtime() returns the current Unix timestamp with microseconds. This function is only available on operating systems that support the gettimeofday() system call.

然后我使用该功能生成唯一的新预订代码:

$newBookingCode = "R".$validNextMySQLInsertId."A".$this->getIncrementalHash(5);

谢谢!

数组取消引用,即从 returns 数组的函数中获取结果,如:

$now = explode(' ', microtime())[1];

可用自 php5.4

对于 php5.3 及更早的用途:

$now = explode(' ', microtime());
$now = $now[1];