What role does the use of entities like ä play in handling special characters in PHP, and when should they be used versus relying on UTF-8 encoding?

Special characters like ä are used in PHP to represent characters that may not display correctly in all environments. This can be particularly useful when dealing with legacy systems or when UTF-8 encoding is not fully supported. However, it is generally recommended to use UTF-8 encoding whenever possible for better compatibility and readability.

$text = "Möller";
echo html_entity_decode($text, ENT_QUOTES, 'UTF-8');