PHP有没有类似JS setTimeout的函数
2 回答
jeck猫
TA贡献1909条经验 获得超7个赞
没有,不过可以通过sleep函数来实现。
代码:
| 1234567891011121314151617 | function setTimeout($func, $sec = 0, $timeout = 0, $args = array()) { if (!function_exists($func) || $timeout == 0) { return false; } while ($timeout > 0) { if (!empty($args) && is_array($args)) { call_user_func_array($func, $args); } else { call_user_func($func, $args); } flush(); ob_flush(); sleep($sec); $timeout--; } return false;} |
- 2 回答
- 0 关注
- 811 浏览
添加回答
举报
0/150
提交
取消
