[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 1; $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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
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 1; $j++) $m = $j *3; } Or look in the http://www.php.net/manual/en/function.microtime.php for examples. -Original Message- From: Rosen [mailto:[EMAIL PROTECTED]] Sent: August 31, 2001 3:29 PM To: [EMAIL PROTECTED] 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 1; $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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with microtime()
?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: [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 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 1; $j++) $m = $j *3; } Or look in the http://www.php.net/manual/en/function.microtime.php for examples. -Original Message- From: Rosen [mailto:[EMAIL PROTECTED]] Sent: August 31, 2001 3:29 PM To: [EMAIL PROTECTED] 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 1; $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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with microtime()
Hi, The problem is, thath I want to generate random number between 1 and 1 How can I do it ? Thanks, Rosen Lawrence Sheed [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED] ... 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 1; $j++) $m = $j *3; } Or look in the http://www.php.net/manual/en/function.microtime.php for examples. -Original Message- From: Rosen [mailto:[EMAIL PROTECTED]] Sent: August 31, 2001 3:29 PM To: [EMAIL PROTECTED] 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 1; $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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]