Question

I'm trying to build a blog/messageboard that uses static HTML files to serve content. I know MovableType used to manage their blog engiene this way, but using Perl CGI scripts. How do I edit/append to HTML files preferebly using PHP? What other methods would people reccommend?

Was it helpful?

Solution

In php there are many file manipulation functions. Read more about them here. Here's a quick example creating an html file:

<?php

file_put_contents('an_html_file.html', "This will be in the html file.");

?>

OTHER TIPS

If you want to just edit the files as raw text:

http://us.php.net/manual/en/ref.filesystem.php

If you want to work with actual HTML DOM:

http://us.php.net/manual/en/book.dom.php

(and specifically, loadHTMLFile() and saveHTMLFile())

Depending on how much work you want to do you could just use fopen and friends.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top