我有Users表,其中包含以下数据:
class User extends Entity
{
protected $_virtual = ['createdformated','modifiedformated'];
protected function _getCreatedformated()
{
$date = new Time($this->_properties['created']);
$final=strftime("%d/%m/%Y %H:%M", $date->getTimestamp());
return $final;
}
protected function _getModifiedformated()
{
$date = new Time($this->_properties['modified']);
$final=strftime("%d/%m/%Y %H:%M", $date->getTimestamp());
return $final;
}
}
如果在我的控制器中,我打电话:
$logusers["data"] = $this->Logusers->find('all')
->contain(['Users'])
->order(['Logusers.id'=>'DESC']);
echo json_encode($logusers);
我在jsonenconde之后得到以下内容
Warning (512): Unable to emit headers. Headers sent in file=C:\wamp\www\otras\mailing\src\Controller\UsersController.php line=91 [CORE\src\Http\ResponseEmitter.php, line 48]
如果我只留下1(一)个虚拟字段,问题就消失了......只有当我启用这两个虚拟字段时才会出现问题。
问题是什么???