Either write CSV first and then send it through readfileor write it immediately to the output stream:
fputcsv(
fopen('php://output', 'w+'),
array(
'Some text',
'Some text with commas ,,,,,',
'Other text'
)
);
which will then print
"Some text","Some text with commas ,,,,,","Other text"
, fputcsv , , , .
. PHP fopen: