我有问题。我已经制作了一个表单,登录用户可以注册成为摄影师。 这一切都很棒。在该页面上,我通过查看摄影师对象是否为空来检查用户是否已经是摄影师。
像这样:if(!empty($this->user->oPhotographer)){
$this->doRedirect('alreadyapplied');
}
现在当我在var_dump
上!empty($this->user->oPhotographer)
时
它返回bool(false)
。它不应该返回它,它应该返回true,因为即时测试与具有填充的摄影师对象的用户。
现在奇怪的是:
echo '<pre>'.var_dump(!empty($this->user->oPhotographer)).'</pre>';
if(!empty($this->user->oPhotographer)){
$this->doRedirect('alreadyapplied');
}
echo '<pre>';
var_dump(!empty($this->user->oPhotographer));
print_r($this->user->oPhotographer);
echo '</pre>';
当对象不为空时,这段代码应重定向到正确的页面。 var_dump仍然给出false,因为它没有重定向。这是代码输出:
bool(false)
bool(false)
photographer Object
(
[table] => photographer
[data] =>
[className] =>
[arFields] => Array
(
[id] => id
[country] => country
[dateofbirth] => dateofbirth
[street] => street
[city] => city
[about] => about
[dateapplied] => dateapplied
[user_id] => user_id
[phone] => phone
[zip] => zip
)
[id] => 1
[country] => ...
[dateofbirth] => ...
[street] => ...
[city] => ...
[about] =>
[dateapplied] => 2013-04-28 19:41:08
[user_id] => 15
[phone] => ...
[zip] => ...
)
当摄影师实际上不是空的时候怎么会返回假?
感谢您的帮助!!