How do I edit HTML files directly?

怎甘沉沦 提交于 2019-12-23 02:01:32

问题


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?


回答1:


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.");

?>



回答2:


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())




回答3:


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



来源:https://stackoverflow.com/questions/1413691/how-do-i-edit-html-files-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!