سلام
این کدهای بنده :
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('school');
mysql_query('set names "utf8"');
// output headers so that the file is downloaded rather than displayed
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
// create a file pointer connected to the output stream
$output = fopen('php://output', 'w');
// output the column headings
fputcsv($output, array('Column 1', 'Column 2', 'Column 3'));
// fetch the data
$rows = mysql_query('SELECT * FROM student');
// loop over the rows, outputting them
while ($row = mysql_fetch_assoc($rows)) fputcsv($output, $row);
?>
عبارت های فارسی :
66.png
اگر از کد :
mysql_query('set names "utf8"');
قبل از کوئری یا کد انتخاب بانک استفاده کنم ، نتیجه :
67.png
در صفحه تگ متا utf-8 موجوده و کالکشن بانک و جدول هم بر همین اساس ایجاد شده است.