PHP标头问题

In my system, I have fetching all data and exporting in txt file.

$str_res_exp = $this->export_res($column ,$res_data,$column_length); 
header("Content-type: plain/text");
header("Content-Disposition: attachment; filename=".$_POST['txt_name'].".txt");
header("Pragma: no-cache");
header("Expires: 0");
echo $str_res_exp;
exit;

it displays data but but on first line, first character it fills white space...

due to security reason i cant post more code.

Try Using trim() function in PHP:

echo trim($str_res_exp); 

http://php.net/manual/en/function.trim.php

Try this:

ob_start(); // put this at the beginning of your scripts

$str_res_exp = $this->export_res($column ,$res_data,$column_length); 
header("Content-type: plain/text");
header("Content-Disposition: attachment; filename=".$_POST['txt_name'].".txt");
header("Pragma: no-cache");
header("Expires: 0");
ob_end_clean();
echo $str_res_exp;
exit;

What type of server are you using?