What is the recommended method to ensure proper character encoding when including text files in a webpage using PHP?
When including text files in a webpage using PHP, it is important to ensure that the character encoding is properly set to avoid displaying garbled text. One recommended method to ensure proper character encoding is to use the `header()` function in PHP to set the Content-Type header with the appropriate charset. This will specify the character encoding of the text file being included in the webpage.
<?php
header('Content-Type: text/html; charset=utf-8');
$text_file = file_get_contents('example.txt');
echo $text_file;
?>