i want to check a string contains unwanted character or not. I want to allow only a string which will contains only @ _ a-z . I want if the string contains anything except this character will give me a false output. i want to check a string which will return true if the string doesn't contains my expected characters.
I tried to use preg_match to do this. But unable to do this. I think preg_match isnot the function i need for this. Please suggest me the best way to reach my desire goal.
$text='Hel&o';
if(!preg_match("/.@_[a-zA-Z0-9]/", $text) ){
return false;
}else {
return true;
}