What are the best practices for searching for a specific word in a user input text using PHP?

When searching for a specific word in user input text using PHP, it is important to sanitize the input to prevent any malicious code injection. One way to do this is by using the `htmlspecialchars()` function to escape special characters. Next, you can use the `strpos()` function to check if the specific word exists in the sanitized user input text.

// Sanitize user input
$user_input = htmlspecialchars($_POST['user_input']);

// Search for specific word
$specific_word = 'example';
if (strpos($user_input, $specific_word) !== false) {
    echo "The specific word '$specific_word' was found in the user input.";
} else {
    echo "The specific word '$specific_word' was not found in the user input.";
}