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? 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 } 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 @ 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 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
Archived
This topic is now archived and is closed to further replies.