php - the function on Model doesn't work well -


i wanna ask validation on yii. i've put validation on model :

public function cekdigit($attribute,$params)     {         $subject=substr($attribute,0,2);         $pattern=$this->string2;         if ($subject!==$pattern)             {                 $this->adderror($attribute, $params['message']);                 return false;             }     } 

while ran that, turned on error message, condition true. meant, when put same string (which matched) still got error. how can fix becomes valid condition?

thanks

instead of if ($subject!==$pattern)

you might want use if (strcmp($subject,$pattern) == 0)


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -