[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

php echo to a txt file

I create my ouput string and then:

 echo $output;

It goes to the display

How can I send it to a text file instead?
0
robrodp
Asked:
robrodp
  • 2
1 Solution
 
haloexpertsexchangeCommented:
do you want to add to a file or write to a new file?
If you want to add to a file then you can do this
$reused = file_get_contents($pathToFile);<-- this gives you a string of current file contents
$add = "New content"
$updated = $reused . $add;
file_put_contents($pathToFIle, $updated);<-- writes out updated file

Open in new window



0
 
haloexpertsexchangeCommented:
If you want just a new file that you can skip the first part and just do the file_put_contents to write out a brand new file.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now