yoyo
yoyo

Reputation: 1133

How to save text into a UTF-8 file with/without BOM in PHP?

Does PHP have such options when saving file?

Upvotes: 1

Views: 1487

Answers (2)

Idealmind
Idealmind

Reputation: 1298

It works for me. Thanks! $file = fopen("arquivos_gerados/teste.html","w"); fwrite($file,chr(0xEF).chr(0xBB).chr(0xBF).$content); fclose($file);

Upvotes: 0

Pekka
Pekka

Reputation: 449395

PHP will never automatically append a BOM when writing a file. You would have to add it yourself:

$filecontents = chr(0xEF).chr(0xBB).chr(0xBF).$mycontents; 

Upvotes: 4

Related Questions