简体   繁体   中英

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. 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?

I was thinking about to get EST and then put if the condition

 (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?

You can put it in a tick-function. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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