What PHP function can be used to replace German umlauts with their corresponding HTML codes?
To replace German umlauts with their corresponding HTML codes in PHP, you can use the `htmlentities()` function. This function will convert special characters, like umlauts, into their HTML entity equivalents. By using this function, you can ensure that the umlauts are displayed correctly on web pages.
$text = "Möchten Sie ein Bier trinken?";
$encoded_text = htmlentities($text, ENT_COMPAT, 'UTF-8');
echo $encoded_text;