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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -