What are common issues with different character encoding in PHP when retrieving data from a database?

Common issues with different character encoding in PHP when retrieving data from a database include garbled or incorrectly displayed characters due to mismatched encodings between the database and PHP script. To solve this issue, you can set the character encoding for the database connection and ensure that PHP is also using the same encoding when retrieving and displaying data.

// Set character encoding for the database connection
mysqli_set_charset($connection, "utf8");

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