How to delay program execution using sleep() function in PHP
sleep('amount of time in seconds') function basically delays our program execution for a perticular fraction of seconds, on success it returns zero and on error it returns false.
Example :-
public function useSleep(){
try{
// current time
echo date('h:i:s') . "\n";
// sleep for 10 seconds
sleep(10);
// wake up !
echo date('h:i:s');
}
catch(\Exception $e){
return false;
}
}
Thank you for reading this article 😊
For any query do not hesitate to comment 💬
-min.png)