请告诉我为什么使用;睡眠();在PHP的pthreads中
请告诉我为什么使用;睡眠();在PHP的pthreads中,php,pthreads,Php,Pthreads,请告诉我为什么在PHP的pthreads中使用“sleep()”sleep用于将程序执行延迟给定的秒数。在phthreads中 sleep()函数将当前脚本的执行延迟指定的秒数 <html> <body> <?php echo date('h:i:s') . "<br>"; //sleep for 10 seconds sleep(10); //start again echo date('h:i:s'); ?> </body>
请告诉我为什么在PHP的pthreads中使用“sleep()”sleep用于将程序执行延迟给定的秒数。在phthreads中 sleep()函数将当前脚本的执行延迟指定的秒数
<html>
<body>
<?php
echo date('h:i:s') . "<br>";
//sleep for 10 seconds
sleep(10);
//start again
echo date('h:i:s');
?>
</body>
</html>
多种用途。例如,在发出curl请求时,您可能希望在发送多个请求之间有一个延迟。或者发送邮件之间的延迟。我不知道为什么会在您的示例中使用它,也许当您了解这个函数的作用时(如果您不知道),您会发现为什么会在代码中使用它?我不知道..谢谢,我对pthreads的知识有限。:)