reference/datetime/functions/microtime.xml
5c951013ca04161992efed8b86fb40f55669958e
...
...
@@ -9,8 +9,8 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>mixed</type><methodname>microtime</methodname>
13
-
<methodparam choice="opt"><type>bool</type><parameter>getAsFloat</parameter><initializer>&false;</initializer></methodparam>
12
+
<type class="union"><type>string</type><type>float</type></type><methodname>microtime</methodname>
13
+
<methodparam choice="opt"><type>bool</type><parameter>as_float</parameter><initializer>&false;</initializer></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
16
<function>microtime</function> returns the current Unix timestamp with
...
...
@@ -27,7 +27,7 @@
27
27
<para>
28
28
<variablelist>
29
29
<varlistentry>
30
-
<term><parameter>getAsFloat</parameter></term>
30
+
<term><parameter>as_float</parameter></term>
31
31
<listitem>
32
32
<para>
33
33
If used and set to &true;, <function>microtime</function> will return a
...
...
@@ -47,10 +47,10 @@
47
47
the form "msec sec", where <literal>sec</literal> is the number of seconds
48
48
since the Unix epoch (0:00:00 January 1,1970 GMT), and <literal>msec</literal>
49
49
measures microseconds that have elapsed since <literal>sec</literal>
50
-
and is also expressed in seconds.
50
+
and is also expressed in seconds as a decimal fraction.
51
51
</para>
52
52
<para>
53
-
If <parameter>getAsFloat</parameter> is set to &true;, then
53
+
If <parameter>as_float</parameter> is set to &true;, then
54
54
<function>microtime</function> returns a <type>float</type>, which
55
55
represents the current time in seconds since the Unix epoch accurate to the
56
56
nearest microsecond.
...
...
@@ -61,34 +61,7 @@
61
61
&reftitle.examples;
62
62
<para>
63
63
<example>
64
-
<title>Timing script execution with <function>microtime</function></title>
65
-
<programlisting role="php">
66
-
<![CDATA[
67
-
<?php
68
-
/**
69
-
* Simple function to replicate PHP 5 behaviour
70
-
*/
71
-
function microtime_float()
72
-
{
73
-
list($usec, $sec) = explode(" ", microtime());
74
-
return ((float)$usec + (float)$sec);
75
-
}
76
-

77
-
$time_start = microtime_float();
78
-

79
-
// Sleep for a while
80
-
usleep(100);
81
-

82
-
$time_end = microtime_float();
83
-
$time = $time_end - $time_start;
84
-

85
-
echo "Did nothing in $time seconds\n";
86
-
?>
87
-
]]>
88
-
</programlisting>
89
-
</example>
90
-
<example>
91
-
<title>Timing script execution in PHP 5</title>
64
+
<title>Timing script execution</title>
92
65
<programlisting role="php">
93
66
<![CDATA[
94
67
<?php
...
...
@@ -106,14 +79,14 @@ echo "Did nothing in $time seconds\n";
106
79
</programlisting>
107
80
</example>
108
81
<example>
109
-
<title><function>microtime</function> and <literal>REQUEST_TIME_FLOAT</literal> (as of PHP 5.4.0)</title>
82
+
<title><function>microtime</function> and <literal>REQUEST_TIME_FLOAT</literal></title>
110
83
<programlisting role="php">
111
84
<![CDATA[
112
85
<?php
113
86
// Randomize sleeping time
114
87
usleep(mt_rand(100, 10000));
115
88

116
-
// As of PHP 5.4.0, REQUEST_TIME_FLOAT is available in the $_SERVER superglobal array.
89
+
// REQUEST_TIME_FLOAT is available in the $_SERVER superglobal array.
117
90
// It contains the timestamp of the start of the request with microsecond precision.
118
91
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
119
92

...
...
@@ -135,7 +108,6 @@ echo "Did nothing in $time seconds\n";
135
108
</para>
136
109
</refsect1>
137
110
</refentry>
138
-

139
111
<!-- Keep this comment at the end of the file
140
112
Local variables:
141
113
mode: sgml
142
114