Working with string php [duplicate]

4

I have a project to issue the bank transfer file for banks and credit unions. In the assembly of the file I define a variable and I add the lines as in the example below:

$conteudo .= '085';                                                        
$conteudo .= '0000';                                                       
$conteudo .= '0';

I would like to know if it is possible to generate this information in file format and force the download without physically creating the file on the server.

    
asked by anonymous 04.01.2017 / 19:22

1 answer

4

Yes, this should resolve:

$fileName = "remessa.txt"; //colocar aqui o nome do arquivo



header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream;");
header("Content-Length:".strlen($conteudo));
header("Content-disposition: attachment; filename=".$fileName);
die($conteudo);
    
04.01.2017 / 19:25