使用什么? time()函数或$ _SERVER ['REQUEST_TIME']吗?哪个更好? [英] What to use ? time() function or $_SERVER['REQUEST_TIME'] ? Which is better?

查看:80
本文介绍了使用什么? time()函数或$ _SERVER ['REQUEST_TIME']吗?哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个时间函数中哪个哪个更好?

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.

所以我想使用一种在执行时不占用任何睡眠的程序.另外,$_SERVER['REQUEST_TIME']time()有何独特之处?两者每隔一微秒都会改变一次吗?

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?

每次提交表单时,$ _ SERVER ['REQUEST_TIME']会更改吗?像一样,time()函数将在每个时间差处改变.

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

我需要给用户一个唯一的URL进行验证,其中要附加从这两个中的任何一个生成的唯一结果?另外,使用microtime()会使PHP入睡吗?是吗?

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?

推荐答案

这要视情况而定.

$_SERVER['REQUEST_TIME']对应于请求开始的时间,Web服务器提供此数据.

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

time()实际上运行系统调用以检查调用此行的时间.

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.

这篇关于使用什么? time()函数或$ _SERVER ['REQUEST_TIME']吗?哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆