Embedding HTML in your PHP is one of the worst decisions you can make. Not only is it a pain to write, it's also a pain to maintain. If you use a fully-fledged framework like Laravel, then you don't have to worry about how HTML is generated. But if you're using bare-metal PHP, you should use a template engine.
In this Coffee Break Course, Envato Tuts+ instructor Jeremy McPeak will introduce you to Twig: a flexible, fast, and secure template engine for PHP. You'll get familiar with its easy-to-learn syntax as Jeremy shows you how to inherit templates and create content blocks.
1. Twig Template Engine for PHP
[SOUND] One of the worst decisions you can make is embedding HTML in your PHP code. Because someday in the future you're going to have to change it and it will not be fun. Now if you're using a fully fledged framework like Laravel, you don't really have to worry about that. But if you don't, then you need a template engine. Hi, my name is Jeremy McPeak and over the next few minutes I'm going to introduce you to Twig, the flexible, fast and secure template engine for PHP. Twig makes it easy to build and use templates within your PHP application. Thanks to its concise and template-oriented syntax, it supports everything you need to build powerful templates with ease. Things like multiple inheritance, content blocks, automatic output escaping and so much more. Come spend the next few minutes with me and we'll take a look at some of these features together.