php: download variable content as file

前端 未结 2 442
孤城傲影
孤城傲影 2021-02-05 19:40

Is the subject possible? I have a script executing. At one point I have a large piece of text in a variable. Could I make it available as a downloadable file without actually wr

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 19:45

    If you mean letting the user click a link and have a dialog box pop up to save certain content as a text file:

    
    

    Is that what you're aiming at? Also, you might want to write a few lines that only allows the headers to be sent this way if a certain $_POST or $_GET variable is set.

提交回复
热议问题