php
中是否有与javascript
setTimeout
方法等效的方法?
我知道php不是多线程的,但我可能是错的。
不,没有。主要是因为 PHP 是服务器端的,所以有定时事件没有多大意义。但是,有一个sleep
函数会在给定的时间内停止执行。
您可以使用pthreads
在PHP中进行多线程处理
来自 PHP 手册:
pthreads is an Object Orientated API that allows user-land multi-threading in PHP.
It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console.
PHP applications can create, read, write, execute and synchronize with Threads, Workers and Stackables.
引用
1) http://www.reddit.com/r/PHP/comments/1jo517/multithreading_in_php_with_pthreads/
2) https://github.com/krakjoe/pthreads
PHP 有线程,所以你可以像在其他多线程语言中一样fork
。
当然,您始终可以创建自己的事件循环;)
你不可能得到一个JS等价物。 与此无关。是不同的技术。
我不知道在做什么。 但是,您可以为 php.ini 文件设置max_execution_time或在脚本级别覆盖该值。
看看
http://php.net/manual/en/function.set-time-limit.php