What are the potential issues with using nl2br(htmlentities()) to display text with umlauts in PHP?

Using nl2br(htmlentities()) to display text with umlauts in PHP may lead to double encoding, where special characters like umlauts are encoded twice. To solve this issue, you can use htmlspecialchars() instead of htmlentities() to encode special characters only once.

$text = "Möglichkeiten für Überprüfung";
echo nl2br(htmlspecialchars($text));