Forum Moderators: coopster

Message Too Old, No Replies

Does anyone know how long How long is 1000000 in microtime is?

         

Simone100

12:33 pm on Sep 8, 2006 (gmt 0)

10+ Year Member



Hi just wondering what 1000000 in microtime is? Is that less than seconds? Can't find the description manual for it. Thanks!

briggidere

1:18 pm on Sep 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



as far as i am aware it is 1 second.

coopster

1:49 pm on Sep 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



microtime() [php.net] returns the current Unix timestamp with microseconds. This function is only available on operating systems that support the gettimeofday() [php.net] system call.

Simone100

1:48 am on Sep 9, 2006 (gmt 0)

10+ Year Member



Coopster do you know if thats correct? If its one second?

And do you suggest using something else since it is only supported
somewhat? Thanks! Simone

coopster

2:23 am on Sep 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Perhaps it would be better if you explain what/how you are using it. We can go from there. I have a feeling that without a further explanation we might be heading down a wrong path ;)

Simone100

6:32 am on Sep 9, 2006 (gmt 0)

10+ Year Member



Sure thing and here's a wink back ;).

Here is the string. srand ((double)microtime()*1000000);

It is supposed to rotate banners I have in seperate text files but I notice it doesn't work. That could be because of the reason you gave as I am sure I have everything set up properly. And the .txt files show on my page so I know that part works, it just is not rotating them, only rotating on onload.

Please tell me how long in time that is supposed to be and if most servers support something better than microtime. Thanks much! :)

jatar_k

3:58 pm on Sep 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> only rotating on onload

so you get a random image each time you reload, this would be the expected behaviour as php is server side. Once the page is delivered to the user php has no more control over it until they make a new request to the server.

If you are trying to get images to rotate while the user sits on the same page then you should look at javascript, which is client side.

Simone100

11:51 pm on Sep 9, 2006 (gmt 0)

10+ Year Member



Why did they put a micro command instead of just a random one in the string? Wondering if I should change this string.

Thanks.

rokec

8:40 am on Sep 10, 2006 (gmt 0)

10+ Year Member



micro = 10-6. According to this 1000000 microsecounds = 1 secound.

In php there isn't any random() function. You must calculate random manually. Because microsecounds are the most random, we use them for script.

Hope helped you a bit.

Simone100

10:12 am on Sep 10, 2006 (gmt 0)

10+ Year Member



OK yes, thanks!

Simone100

10:14 am on Sep 10, 2006 (gmt 0)

10+ Year Member



Whooops forgot to ask. Any other good scripts besides javascript that are good with second, minute, hour timers? Thanks :) :)

rokec

12:06 pm on Sep 10, 2006 (gmt 0)

10+ Year Member



Php is good, too.

Simone100

12:30 pm on Sep 10, 2006 (gmt 0)

10+ Year Member



Well not really I guess, I was told php bad for timers besides page onload.

rokec

1:01 pm on Sep 10, 2006 (gmt 0)

10+ Year Member



Yes, php is just for calculating time, not to show the timer on webpage. Php page is generated by server. For timers on webpage you must use javasript.

rokec

4:42 pm on Sep 10, 2006 (gmt 0)

10+ Year Member



If you want really powerful timers, you must combine using java and php. Php is doing functions server-side and java is doing functions client-side.

Simone100

12:25 am on Sep 11, 2006 (gmt 0)

10+ Year Member



Thanks, java or javascript?

jatar_k

5:16 am on Sep 11, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



javascript

Simone100

5:51 am on Sep 11, 2006 (gmt 0)

10+ Year Member



Thanks, does anyone know how you would link the two together? You don't have to give me any code, I already have my own javascript and php. I just don't know how a person would link the two together.

For instance lets say the javascript does the timer work, because thats what you are all saying javascript is the best for hour second and minute timers. The timers js code I can figure out on my own.

How would I call on the javascript function using php? By just using a php include command? Kind of thinking out loud here. Doesn't seem like that would work because to use the php include my page I am calling on has to be named something.php and javascript files end in .js. See what I am getting at? Not sure how you would use the two together. Just trying to learn something new here, hope someone knows a little bit about this to help me out. Thank you very much!

pixeltierra

3:06 pm on Sep 11, 2006 (gmt 0)

10+ Year Member



Simone100: I think the thing you need to learn here is the diffence between something that is server-side and something that is client-side. I'm sure there are a million tutorials on this out there.

Php executes on the server and determines what is sent to the client (browser). Once sent, php is no longer involved unless you make another server request.

If you want to change something on a page after it is sent to the client without making another server request (a new page or AJAX-which is javascript anyway), then you have to use javascript.

So in a nutshell php runs on servers to do stuff, and javascript runs in browsers to do stuff. Something that also might be confusing you is that javascript is not java, which is an entirely different can of worms.

Hope this is useful.

mcavic

4:36 pm on Sep 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In php there isn't any random() function.

It's rand()

Simone100

6:35 am on Sep 12, 2006 (gmt 0)

10+ Year Member



Thanks, everyone, I have a hard time thinking that javascript is the only one that will do these sort of timer issues, besides daily and random timers, with all the scripts out there, is it really true?

Also, I was only trying to figure out how you use them together, because the above posts said that I could.

From what your saying though is in order to use them together for the timer issue, the javascript would have to call on the php not the other way around like I suggested.

But since php won't do hour, minute, second issues as stated above, would there be any reason at all to use them together in timer issues?

Knowing these things will clear up a lot!