我有以下代码无法正常工作:
class Tfping extends Worker {
protected $complete;
public function __construct($status) {
$this->complete = $status;
//print_r($this->complete);
}
public function run() {
$this->complete['result'] = "result";
print_r($this->complete);
}
public function isComplete() {
return $this->complete;
}
}
$status['content'] = $row['content'];
$status['id'] = $row['id'];
$status['name'] = $row['name'];
$status['last_up'] = $row['up'];
$status['type'] = "fping";
$pool->submit(new Tfping($status));
我得到的是:
Array
(
[content] => "content"
[id] => 24
[name] => "name"
[last_up] => 0
[type] => "type"
)
我的期望是:
Array
(
[content] => "content"
[id] => 24
[name] => "name"
[last_up] => 0
[type] => "type"
[result] => "result"
)
为什么不起作用?如果我做了$ complete ['result'] =“result”; $ this->完成= $完成;然后设置变量,但在我的情况下我不能这样做,因为旧的数组值将被覆盖,这不是我想要的。 谢谢您的帮助。