How can I write a file in UTF-8 format? April 14, 2023 by Tarik Add BOM: UTF-8 file_put_contents($myFile, "\xEF\xBB\xBF". $content);