How can the correct encoding be specified in the HTTP header for PHP scripts?

When sending data from a PHP script to a client, it's important to specify the correct encoding in the HTTP header to ensure that the data is displayed correctly. This can be done by setting the "Content-Type" header with the appropriate charset parameter. For example, if you want to use UTF-8 encoding, you would set the header like this: "header('Content-Type: text/html; charset=UTF-8');".

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