©
本文档使用 PHP中文网手册 发布
(PECL pthreads >= 2.0.1)
Thread::globally — 执行
在全局范围中执行代码块
此函数没有参数。
被调用代码块的返回值
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) { }
[#1] SolutionFix [2015-03-17 15:27:51]
"This function has no parameters" and "void" in description, but in example unnamed function passed. Looks like parameter not "void", but "callable".