What are best practices for setting character encoding in PHP scripts and databases to avoid Umlaut display problems?

When dealing with Umlaut display problems in PHP scripts and databases, it is important to ensure that the character encoding is consistent across all components. Set the character encoding to UTF-8 in both your PHP scripts and your database to properly handle Umlaut characters.

// Set character encoding in PHP script
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding('UTF-8');

// Set character encoding in database connection
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase;charset=utf8', 'username', 'password');