将网站存储在 HTML 中而不是数据库中
您能为我推荐一种解决我的问题的好技术吗?我有一个博客,现在它是一个经典的动态页面 MySql + Php + Javascript。但我会重写它。如果发生用户事件,即用户发布评论,我不会将其存储在数据库中,而是将更改存储在 HTML 文件中。所以逻辑不在php文件中,而是在html文件中。我怎样才能做到这一点,但以一种简单的方式。
Could you recommend me a nice technology for my problem? I had a blog and now it as a classical dynamic page MySql + Php + Javascript. But i would rewrite it. If an user event happend, i.e. a user posted a comment, i wouldn't store it in database, but store the changes in an HTML file. So the logic is not in the php file but in html file. How can i do that, but in an easy way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理论上,您可以在用户事件(即:POST)之后解析静态 html 文件并将结果附加到 html,写回文件,但是我不会推荐它,因为脚本必须相当复杂才能处理html 正确。
You could theoretically parse the static html file after a user event (i.e.: POST) and append the result to the html, write back to the file, however I wouldn't recommend it as the script would have to be fairly complex to handle the html correctly.
如果您想在用户发表评论时编辑静态 HTML 文件,恕我直言,这是一个不好的方法。例如,您将如何实现搜索?
不要尝试复制数据库正在做的事情,因为编写数据库的人一生都在做这件事。
您可能想要搜索现有的博客解决方案,而不是从头开始编写解决方案。有许多用多种语言/平台编写的开源项目。
If you want to edit static HTML files when the user posts a comment than it is a bad approach IMHO. How would you implement searching, for example?
Don't try replicating what database is doing, because the guys that wrote database spend their whole lives doing just that.
You might want to search for existing blog solutions instead of writing one from scratch. There are many open-source projects written in many languages / platforms.