What is the best way to insert HTML via PHP?

前端 未结 11 2138
南方客
南方客 2020-12-12 15:26

Talking from a \'best practice\' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the lat

11条回答
  •  鱼传尺愫
    2020-12-12 16:22

    Neither. Use Smarty. By separating your internal logic from the display logic you will build code that is much simpler to maintain. (Don't take the path of PHPLib's old template system that tried to completely separate PHP and HTML - it requires display logic to be intermingled with your core business logic and is very messy.) If you absolutely must generate HTML snippets in your PHP code, use your 2nd method, but pass the variable to Smarty.

提交回复
热议问题