-1

我在该行有一个语法错误:return (double) + (double);

   public function getMicroTime( )
    {
        list( $usec, $sec ) = explode( " ", microtime( ) );
        return (double) + (double);
    }

你能帮我解决这个问题吗?

4

2 回答 2

2

The (double) type cast behaves much like a unary operator and thus requires an argument next to it. You should return the following instead:

return (double)$usec + (double)$sec;

However, since 5.0, your whole function can be replaced by simply this:

microtime(true);

By passing true as the first argument, it returns the time as a float with ms accuracy.

于 2012-12-31T02:42:38.010 回答
1

google finds this, based on your vars, you may be missing something in your copy and paste skills :-)

function getmicrotime($t) {  
 list($usec, $sec) = explode(" ",$t);  
 return ((float)$usec + (float)$sec);  
} 
于 2012-12-31T02:44:37.837 回答