简体   繁体   English

PHP-休眠两​​个脚本

[英]PHP - sleep two scripts

I have one question for you. 我有一个问题要问你。 I'm coding in PHP, and I have one program that uses two PHP files, one main file and second file where are functions and etc, that I'm calling in the main file. 我使用PHP进行编码,并且我有一个程序使用两个PHP文件,一个是主文件,另一个是函数等,在主文件中调用该文件。 They are very big scripts with a lot of lines of code. 它们是非常大的脚本,包含很多代码行。

I want to sleep my program at a certain time from 2 pm to 5 pm EST, but I have a problem how I can write code to sleep program in that period? 我想在美国东部标准时间下午2点到下午5点之间的某个时间休眠我的程序,但是我有一个问题,在那个时期我该如何编写代码来休眠程序?

I was thinking about to get EST and then put if the condition 我当时正在考虑获取EST,然后根据情况

 (if servertime === EST){
sleep(108000);
}

But my big problem is that I have a lot of functions and classes, how to make this globally, to put this in every function, so whenever come 2pmEST, program should go to sleep wherever the function was at that moment? 但是我最大的问题是我有很多函数和类,如何全局创建该函数并将其放入每个函数中,所以每当2pmEST到来时,程序应该在那个函数所在的那个地方都进入睡眠状态?

You can put it in a tick-function. 您可以将其置于刻度功能中。 http://php.net/manual/de/function.register-tick-function.php http://php.net/manual/de/function.register-tick-function.php

Be carefully - this will be excuted after each tick - if you dont want it in middle of a prozess, you need check it. 小心-每次打勾后都会被剔除-如果您不希望在中间出现问题,则需要进行检查。

Also look here. 也看这里。 http://php.net/manual/de/control-structures.declare.php http://php.net/manual/de/control-structures.declare.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM