Separate Logic from presentation without using template engine

前端 未结 2 1678
长发绾君心
长发绾君心 2021-01-15 11:25

How can we separate Logic from presentation without using any template engine (traditional php-not OOP) Thank in advance

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 11:35

    Why not to use PHP itself as a template engine? It being used in the code I posted for your other question. Your program has to be split into 2 main sections: getting data and displaying data.

    Each page have to have it's own template. In the code I posted there is 2 very simple templates, form.php and list.php
    just extend it with the whole site template, And you have done!
    Here is a little more complex PHP template example:

    Answer:
    - - show hide edit

    And it is called like this

    
    

    Looks magnificent to me!
    Dunno though, if it's what you're asking for :)

提交回复
热议问题