Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to use ? time() function or $_SERVER['REQUEST_TIME'] ? Which is better?

Which one among these two time functions is better?

I have a form on my website which is submitted by thousands of users every microsecond or less , thus , thousands of requests at the same time on my server.

So I want to use the one which does not uses any sleep while execution. Also , how unique is $_SERVER['REQUEST_TIME'] and time()? Do both change every microsecond?

Will $_SERVER['REQUEST_TIME'] change every time I submit the form? Like , the time() function will change at every time difference.

I need to give a unique url to the user for verification in which am appending the unique result generated from any one of the two? Also, using microtime() would make PHP sleep? isn't it?

like image 750
sqlchild Avatar asked Aug 24 '12 10:08

sqlchild


People also ask

What is $_ SERVER [' Request_time ']?

$_SERVER['REQUEST_TIME'] corresponds to the time when the request has started, the web server provides this data. time() actually runs a syscall in order to check the time when this line is called.

What is Request_time_float?

$_SERVER['REQUEST_TIME_FLOAT'] is set the moment your webserver hands the processing over to PHP. That means it will always be the timestamp PHP starts processing the request. So if you want to measure how long it took PHP to get to a specific point, you can use that.


1 Answers

It depends.

$_SERVER['REQUEST_TIME'] corresponds to the time when the request has started, the web server provides this data.

time() actually runs a syscall in order to check the time when this line is called.

You need to be more specific on what you want to do so we can give you complete answers.

like image 128
Intrepidd Avatar answered Oct 17 '22 00:10

Intrepidd