What are the recommended settings for handling umlauts in a PHP website with MySQL database?

When handling umlauts in a PHP website with a MySQL database, it is recommended to set the character encoding to UTF-8 for both the database connection and the HTML output. This ensures that special characters like umlauts are properly stored and displayed without any encoding issues.

// Set UTF-8 character encoding for MySQL connection
$mysqli = new mysqli("localhost", "username", "password", "database");
$mysqli->set_charset("utf8");

// Set UTF-8 encoding for HTML output
header('Content-Type: text/html; charset=utf-8');