Dynamically generated content to .txt file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spock0149
Forum Newbie
Posts: 10
Joined: Thu Apr 02, 2009 7:37 pm

Dynamically generated content to .txt file

Post by spock0149 »

Hey folks,

We're coding a project in .php and we have a contract that a members of our site agrees to.

It is generated dynamically so that the contract details that are seen on-screen indicate things like the users name.

So, even though it looks like a text file, its generated dynamically.

Question

is it possible to pass the text information and to save whats in there as a simple .txt file, including the info thats generated dynamically?

If so, what sort of commands could I use?

Thanks in advance.

Spock
User avatar
micknc
Forum Contributor
Posts: 115
Joined: Thu Jan 24, 2008 11:13 pm

Re: Dynamically generated content to .txt file

Post by micknc »

There are a couple of associated functions that you should take a look at but here is a good starting point:

fwrite:
http://php.net/manual/en/function.fwrite.php
spock0149
Forum Newbie
Posts: 10
Joined: Thu Apr 02, 2009 7:37 pm

Re: Dynamically generated content to .txt file

Post by spock0149 »

micknc wrote:There are a couple of associated functions that you should take a look at but here is a good starting point:

fwrite:
http://php.net/manual/en/function.fwrite.php
Ok, sounds like good advice. Thanks Micknc.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Dynamically generated content to .txt file

Post by requinix »

You can fake something like a text file with header().

Code: Select all

<?php
 
header("Content-Type: text/plain");
 
echo "This text will be monospaced, just like in a text file.";
Post Reply