php - Return always return false -
the problem function return me 0. why?
public function valid_token () { if (!isset($_session['token']) || $this->token != $_session['token']) { $this->errors[] = "formulario incorrecto"; } return count($this->errors)? 0 : 1; }
edit:
ignore previous answer. stupid falsy values. reason getting 0
in return because...you have value inside of array. @orangepill states in comments, dump values of $this->token
, $_session['token]
see what's going on.
old:
count()
returns number of elements inside array. right running count()
. need compare integer value i.e.:
count($this->errors)>0 ? 0 : 1;
Comments
Post a Comment