Re: Problem with microtime()
| From: | Andrey Hristov | Date: | Fri, 31 Aug 2001 07:52:46 +0000 |
| Subject: | Re: Problem with microtime() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65426@lists.php.net to get a copy of this message | ||
<?php
$a="123 456";
echo (int)$a;
$b=(int) $a;
echo "<br>";
echo $b;
?>
Produces :
123
123
So I don't think that the problem is how PHP makes the casting but the algorithm is useless. Do
that :
$ar=explode(' ',microtime());
$a=$ar[1]+$ar[0];
Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
BALANCED SOLUTIONS
----- Original Message -----
From: <Lawrence.Sheed@dfait-maeci.gc.ca>
To: <rosen_dm@dir.bg>; <php-general@lists.php.net>
Sent: Friday, August 31, 2001 10:42 AM
Subject: RE: [PHP] Problem with microtime()
>
> You are casting microtimes results as an integer value. It isn't an integer
> value, hence the 0.
>
>
> From the manual It returns the string the string "msec sec" where sec is
> the current time measured in the number of seconds since the Unix Epoch
> (0:00:00 January 1, 1970 GMT), and msec is the microseconds part. This
> function is only available on operating systems that support the
> gettimeofday() system call.
>
>
> Try:
>
> for ($i = 0; $i < 100; $i++) {
> $k = microtime();
> echo "<br>$k";
>
> for ($j = 0; $j < 10000; $j++)
> $m = $j *3;
> }
>
> Or look in the
> http://www.php.net/manual/en/function.microtime.php for
> examples.
>
> -----Original Message-----
> From: Rosen [mailto:rosen_dm@dir.bg]
> Sent: August 31, 2001 3:29 PM
> To: php-general@lists.php.net
> Subject: [PHP] Problem with microtime()
>
>
> Hi,
> I'm using the following code:
> for ($i = 0; $i < 100; $i++) {
> $k = (int) microtime();
> echo "<br>$k";
>
> for ($j = 0; $j < 10000; $j++)
> $m = $j *3;
> }
>
>
> but it prints me only "0......"
>
>
>
> Where can be problem ?
>
>
>
> Thanks,
>
> Rosen
>
>
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>