What are the best practices for handling character encoding issues, such as with the EUR symbol, in PHP and MySQL interactions?

Character encoding issues, such as with the EUR symbol, can be resolved by ensuring that the character encoding is consistent between PHP and MySQL. This can be achieved by setting the character set to UTF-8 in both PHP and MySQL to properly handle special characters like the EUR symbol.

// Set UTF-8 encoding in PHP
mysqli_set_charset($connection, 'utf8');

// Set UTF-8 encoding in MySQL
$connection->query("SET NAMES 'utf8'");
$connection->query("SET CHARACTER SET utf8");