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 = "[email protected]"; $result = checkEmail($email1); echo $result; 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)); 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
Archived
This topic is now archived and is closed to further replies.