Can one trust that data received in a PHP script is UTF-8 encoded if the script is saved in UTF-8 without BOM?

When receiving data in a PHP script, it is not safe to assume that the data is UTF-8 encoded just because the script itself is saved in UTF-8 without BOM. To ensure that the data is properly encoded, it is recommended to explicitly set the encoding using functions like mb_detect_encoding() or mb_convert_encoding().

// Set the encoding to UTF-8
$data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));