Page 1 of 1

html generator

Posted: Thu Nov 27, 2003 6:32 am
by pabs
Hi there,

I was wondering if there's a way to generate simple HTML files localy from php files. I realize that the server does this when it parses my php files...but can I somehow dump that to a file on my drive...??

I have a web server at home that supports php so I develop using php

but if I'm building a site on a server that does not support php I would like to be able to create the entire site using php with templates and then generating all the HTLM files I need to upload to the non-php server.


What is the simplest way to do this?

thanks

Pabs

Posted: Thu Nov 27, 2003 6:34 am
by Nay
Maybe: fopen.

You can do a fopen("somefile.html", "w") and if the somefile.html doesn not exist, it'll create somefile.html, then you can write to it.

-Nay

Posted: Thu Nov 27, 2003 7:42 am
by dull1554
i don't know what it is that you want to write to a file, but all you have to do is, like if your gonna pull it in from a form, just define it as a $var and where you see $insertcode thats where you would place what ever you want written to the file, weither its text, html, or a $var

$fp = fopen("somefile.html", "w");
$insertcode = "//the code you would want to use";
fwrite($fp, $insertcode);
fclose($fp);

Posted: Thu Nov 27, 2003 9:59 am
by pabs
not sure if we are on the same page...

What I want to do is create a template using php..
make the entire site using php..then once I have everything ready generate the corresponding HTML files for the pages on the site.
Like I said, the site in question does not support php so I need to dump the parsed php files to corresponding HTML files...

thanks
Pabs

Posted: Thu Nov 27, 2003 10:38 am
by m3mn0n
Yes, php can generate the pages for you. If you research at the [php_man]filesystem[/php_man] section of the manual you will find some good functions to help you solve this dilemma. :)