html generator

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
pabs
Forum Newbie
Posts: 2
Joined: Thu Nov 27, 2003 6:32 am

html generator

Post 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
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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);
pabs
Forum Newbie
Posts: 2
Joined: Thu Nov 27, 2003 6:32 am

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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. :)
Post Reply