Using PHP as a template engine

后端 未结 6 2192
梦毁少年i
梦毁少年i 2020-12-02 00:57

I am not going to argue about the choice of a template engine against only PHP. I choose not to use a template engine, like Smarty, because I would like to learn how to prop

6条回答
  •  臣服心动
    2020-12-02 01:20

    What you might want to consider, if you should opt for a MVC-style approach, if you include your templates inside an object (one of its class methods) then $this inside the template file will point to the object you called it from.

    This can be very useful if you want to ensure some kind of encapsulation for your templates, i.e. if you do not want to rely on global variables to pass around dynamic data (e.g. from a database).

提交回复
热议问题