Is it a good idea to make a PHP website using only DOM? [closed]
Good morning,
I'm making a website in PHP, the "classic way" (mixing html and php). However as the website grows, the code gets ugly. So I was wondering if making the whole website with DOM is a good idea. DOM produces, I think, cleaner code, allow faster modifications in the code . etc.
"DOM" refers to the functions you can find here : http://php.net/manual/en/book.dom.php (开发者_开发知识库createElement, getElementById ...)Is it a good idea to use only DOM ? Or is it a crazy idea ?
Thanks.
No, both ideas are bad. Mixing code and HTML is just terrible. Trying to build whole HTML using DOM is way too inefficient. The way to go is to separate logic and presentation. Later should be done using templates.
Use web framework implementing MVC pattern. There are quite a few of them for PHP.
精彩评论