I was getting this error while trying to do this in php:
if empty($userSession = $this->Session->read('User')) { //do something; }
The solution to get over this is to define a variable before actually testing for its value, as such.
$userSession = $this->Session->read('User'); if empty($userSession) { // do something; }
As a rule of thumb, the php function empty cannot check the return value of a function or method. It can only check variables.
Shailesh says
thanks it save my time
Jan says
thank you! exactly hit the problem! 🙂
rasik says
Fixed in PHP 5.5+
Đỗ Huệ says
thank you.