How can the PHP header function be used to specify character encoding in web pages?

When creating web pages, it is important to specify the character encoding to ensure that special characters and symbols are displayed correctly. This can be done using the PHP header function by setting the Content-Type header to include the charset parameter with the desired encoding, such as UTF-8. This will inform the browser how to interpret the text content of the page.

<?php
header('Content-Type: text/html; charset=UTF-8');
?>