(PECL pthreads < 3.0.0)
Threaded::getTerminationInfo — 错误检测
pthreads v3 中已移除此方法。 另外,Threaded::run() 中的代码, 应该使用 try...catch 来进行异常检测(因为在 PHP 7 中大部分 error 都改为抛出异常的方式了)。
返回对象的终端错误信息
此函数没有参数。
包含终端信息的数组对象
Example #1 检测线程运行时的致命错误
<?php
class My extends Thread {
public function run() {
@not_found();
}
}
$my = new My();
$my->start();
$my->join();
var_dump($my->isTerminated(), $my->getTerminationInfo());
?>
以上例程会输出:
bool(true)
array(4) {
["scope"]=>
string(2) "My"
["function"]=>
string(3) "run"
["file"]=>
string(29) "/usr/src/pthreads/sandbox.php"
["line"]=>
int(4)
}