what is the recommended way to embed html codes inside php codes?

后端 未结 5 753
温柔的废话
温柔的废话 2020-12-11 08:55

Lets say I have 2 cases:


v.s



html codes goes here



        
5条回答
  •  北海茫月
    2020-12-11 09:32

    You should put HTML outside of PHP code in order for better maintenance and scalability. It's also very beneficial to do all your necessary data processing before displaying any data, in order to separate logic and presentation.

    Rather then try to think about constantly separating your php and HTML you should instead be in the mind set of separating your backend logic and display logic.

    The MVC pattern is a good way of thinking about your code - In order to correctly use PHP you must use MVC (model-view-controller) pattern

提交回复
热议问题