Is it recommended to apply HTMLentities and strip_tags functions consecutively on the same content in PHP?

When applying `htmlentities` and `strip_tags` consecutively on the same content in PHP, it is not recommended as it can lead to unexpected results. `htmlentities` converts special characters to HTML entities, while `strip_tags` removes HTML tags from the content. If you apply `strip_tags` after `htmlentities`, it may not work as expected because the special characters have already been converted to HTML entities. To properly sanitize content, it is best to choose one method based on your specific needs.

// Example of applying htmlentities only
$originalContent = "<p>Hello, <strong>world</strong>!</p>";
$sanitizedContent = htmlentities($originalContent);
echo $sanitizedContent;