我在Windows上安装了Zend Server 6.3和Php 5.4。系统工作得很好。现在我将代码移至Live网站,该网站使用DirectAdmin在Ubuntu服务器上运行Php 5.3.29。所有其他网站在那里运行良好。但我目前的网站给我这个错误(该网站上的WordPress 4.3):Php microtime()在现场不工作。寻找解决方法
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 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$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);
}
任何想法如何使其在现场工作?
作为每腓引用http://php.net/manual/en/function.microtime.php 它说:
microtime中()返回当前Unix时间戳和微秒。此 函数仅在支持gettimeofday()系统调用的操作系统上可用。
我使用这个函数生成独特的新预订代码:
$newBookingCode = "R".$validNextMySQLInsertId."A".$this->getIncrementalHash(5);
谢谢!
服务器上的PHP版本? –
Php 5.3.29在服务器上。 – KestutisIT
如果它具有不同版本的PHP,那么它不是一个非常好的测试环境,特别是如果测试环境具有较新版本的PHP,则LIVE环境 – RiggsFolly