【发布时间】:2013-10-04 16:17:01
【问题描述】:
php 中是否有与javascript setTimeout 等效的方法?
我知道 php 不是多线程,但我可能是错的。
【问题讨论】:
-
你到底想完成什么?
标签: php
php 中是否有与javascript setTimeout 等效的方法?
我知道 php 不是多线程,但我可能是错的。
【问题讨论】:
标签: 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/
【讨论】:
PHP 有线程,因此您可以像使用其他多线程语言一样fork。
当然,您总是可以创建自己的事件循环;)
【讨论】:
您无法获得等效的 JS。与此无关。是不同的技术。
我不知道要做什么。但是您可以为 php.ini 文件设置 max_execution_time 或在脚本级别覆盖该值。
看看
【讨论】: