How can one ensure that the correct character encoding format is used to prevent unexpected characters in PHP code?

To ensure that the correct character encoding format is used in PHP code, one can set the encoding explicitly using the `header()` function with the `Content-Type` parameter. This will help prevent unexpected characters from appearing in the output of the PHP code.

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