Hay all,
I know this is going to be really stupid problem, It seems I don't know how to evaluate the returned value from a function that returns true or false.
Here is the function I'm calling
function checkEmail($email) {
$email = trim( $email ); # removes whitespace
if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) {
return false;
}
return true;
}
Here what I do when I call the above function
if ( checkEmail($rqst_mail) )
or I do this
$error = checkEmail($rqst_mail) ;
if ( $error )
I know the function is basically working
because, in the function I changed return false; to return "false" and return true to return "true";
Then changed
if ( $error ) to if ( $error == "true" )
This worked perfectly so my logic seems right?
It seem I can not evaluate the value returned by the function correctly unless the value is in "quotes" I even tried
if ( $error == true ), if ($error),
I just don't see what I'm doing wrong I guess.
shouldn't this work simply like
if ( checkEmail($rqst_mail) )
Thanks for any help