codeboy89 Posted December 1, 2009 Share Posted December 1, 2009 I would like to check text input for the '@' character, and give an error if it is not there. How would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/183499-checking-string-for-certain-character/ Share on other sites More sharing options...
abazoskib Posted December 1, 2009 Share Posted December 1, 2009 if(strpos($searchString,'@') !== false) { ////@ was found } Quote Link to comment https://forums.phpfreaks.com/topic/183499-checking-string-for-certain-character/#findComment-968595 Share on other sites More sharing options...
codeboy89 Posted December 1, 2009 Author Share Posted December 1, 2009 if(strpos($email,'@') !== false) { echo "Error not valid"; exit(); } this does not give and error if the input doesnt contain a @ Quote Link to comment https://forums.phpfreaks.com/topic/183499-checking-string-for-certain-character/#findComment-968612 Share on other sites More sharing options...
mikesta707 Posted December 1, 2009 Share Posted December 1, 2009 it should be if(strpos($email,'@') === false) { http://php.net/manual/en/function.strpos.php Quote Link to comment https://forums.phpfreaks.com/topic/183499-checking-string-for-certain-character/#findComment-968614 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.