kalster Posted August 22, 2012 Share Posted August 22, 2012 why is this code not working? its not printing out the $result which should be either 1 or 0. function checkEmail($email) { if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) { return false; } return true; } $email1 = "h@.com"; $result = checkEmail($email1); echo $result; Quote Link to comment https://forums.phpfreaks.com/topic/267400-cant-get-the-return-value-of-a-function/ Share on other sites More sharing options...
requinix Posted August 22, 2012 Share Posted August 22, 2012 Your function returns a boolean, not an integer. var_dump(checkEmail($email1)); Quote Link to comment https://forums.phpfreaks.com/topic/267400-cant-get-the-return-value-of-a-function/#findComment-1371306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.