【发布时间】:2016-06-30 22:34:33
【问题描述】:
说明:
创建了一个扩展 Thread 的 php 类 ChildThread。它看起来像这样:
use Thread;
class ChildThread extends Thread
{
public $data;
private $anonymous_func;
public function __construct($anonymous_func)
{
$this->anonymous_func = $anonymous_func;
}
public function run(){
$func = $this->anonymous_func;
$this->data = $func();
}
}
问题:
我收到以下错误:
试图从全局命名空间加载类“线程”。你是否 忘记“使用”语句?
我显然有一个use 声明,它使用了正确的类:
/**
* When the start method of a Thread is invoked, the run method code will
* be executed in separate Thread, asynchronously.<br/>After the run method
* is executed the Thread will exit immediately, it will be joined with
* the creating Thread at the approriate time.
* @link http://www.php.net/manual/en/class.thread.php
*/
class Thread extends Threaded implements Traversable, Countable, ArrayAccess {
/** class code here **/
}
问题:
为什么说我需要一个“使用”语句,而我已经在使用一个?
【问题讨论】:
标签: php multithreading symfony