method for creating PHP templates (ie html with variables)?

后端 未结 6 527
北恋
北恋 2021-02-04 21:22

I\'m designing my html emails, these are to be a block of html containing variables that i can store in a $template variable.

My problem comes with the storing in the va

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 21:51

    Don't tie your template to PHP. You may need to support the same template on other platforms in the future.

    What we do is that we use SSI (Server Side Include) echo command to inject variables into HTML. If you don't have SSI support, you can simply replace the vars in PHP with regular expressions. The template looks like this,

    Welcome ,

    Where USERNAME is the variable name. This looks more verbose than simply putting PHP vars in the template but you will benefit in long run.

提交回复
热议问题