What are the best practices for checking if a specific word is present in a sentence using PHP functions like strpos?

To check if a specific word is present in a sentence using PHP functions like strpos, you can use the strpos function to find the position of the word in the sentence. If the word is found, strpos will return the position of the word in the sentence, which can be used to determine if the word is present. You can then check if the position is greater than or equal to 0 to confirm the presence of the word.

$sentence = "This is a sample sentence.";
$word = "sample";

if (strpos($sentence, $word) !== false) {
    echo "The word '$word' is present in the sentence.";
} else {
    echo "The word '$word' is not present in the sentence.";
}