- PHP 手册
- 函数参考
- 进程控制扩展
- pthreads
- Thread
Thread::globally
(PECL pthreads < 3.0.0)
Thread::globally — 执行
Warningpthreads v3 中已移除此方法。
说明
public static Thread::globally ( void ) : mixed在全局范围中执行代码块
参数
此函数没有参数。
返回值
被调用代码块的返回值
范例
Example #1 在全局范围执行代码块
<?php
class My extends Thread {
public function run() {
global $std;
Thread::globally(function(){
$std = new stdClass;
});
var_dump($std);
}
}
$my = new My();
$my->start();
?>
以上例程会输出:
object(stdClass)#3 (0) { }
User Contributed Notes 1 note
up down 12 SolutionFix ¶4 years ago
"This function has no parameters" and "void" in description, but in example unnamed function passed. Looks like parameter not "void", but "callable".
add a note
官方地址:https://www.php.net/manual/en/thread.globally.php