Page 1 of 1

Dynamically generated content to .txt file

Posted: Wed Sep 09, 2009 5:43 am
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

Re: Dynamically generated content to .txt file

Posted: Wed Sep 09, 2009 5:53 am
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

Re: Dynamically generated content to .txt file

Posted: Fri Sep 11, 2009 10:45 pm
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.

Re: Dynamically generated content to .txt file

Posted: Fri Sep 11, 2009 10:56 pm
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.";