In PHP can I check a boolean on a function call?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-03-16T13:20:15Z Indexed on 2010/03/16 13:26 UTC
Read the original article Hit count: 158

Filed under:
|

I have a function which checks the passed value and returns false or true, if false I want it to add something to an array. The code I've written is below.

if(!check_input($_POST['username'])){
    $errors[] = "Username";
}  

Right now it adds to my array anyway, regardless of what is entered in the form. Is the way I've written that the correct way to check if the return from check_input() is false? I've checked the function's logic by altering the returns to echoes and it's returning the correct value, I'm just not sure if I'm checking it wrong.

I'd previously attempted to write it as $X=check_input etc, and then if(check_value == false) but that doesn't seem to give me the desired result either. Hmmm a quick pointer please!

© Stack Overflow or respective owner

Related posts about php

Related posts about boolean