Thumbnail
Category: Lập trình

Kinh nghiệm Export CSV

Date: October 12, 2022
10 views

1. Không bị lỗi mã hóa

Để không bị như trên hãy thêm đoạn code sau vào trước text data.

$fileExport = fopen("text.txt", "w") or die("Unable to open file!");


// thêm vào dòng bên dưới
$line = chr(0xEF) . chr(0xBB) . chr(0xBF);


fwrite($fileExport, $line);
fclose($fileExport);

Bằng cách này file sẽ được chuyển thành UTF8.

Từ khóa reasearch: byte order mark

https://en.wikipedia.org/wiki/Byte_order_mark


Copyright © 2025 All Right Reserved