What potential pitfalls can arise from relying solely on web server settings for character encoding in PHP?

Relying solely on web server settings for character encoding in PHP can lead to inconsistencies and potential security vulnerabilities if the settings are not properly configured. It is best practice to explicitly set the character encoding in your PHP code to ensure consistent and secure handling of character data.

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