$f=fopen("test.txt", "wb"); $text=utf8_encode("�a�!"); // adding header $text="\xEF\xBB\xBF".$text; fputs($f, $text); fclose($f);