All quizzes
Free quiz · 20 questions in the bank

Twig quiz

Test your Twig knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/5Score 0

What does the `~` operator do in a Twig expression, e.g. `{{ 'Hello, ' ~ name ~ '!' }}`?

Questions in this quiz
  1. What does the `~` operator do in a Twig expression, e.g. `{{ 'Hello, ' ~ name ~ '!' }}`?
  2. What is the basic syntax for outputting a variable's value in a Twig template?
  3. What is Twig's "sandbox" mode used for?
  4. How does Twig handle accessing a property or calling a method on a PHP object passed into a template, given the dot syntax like `{{ user.name }}`?
  5. What is the purpose of `{% include %}` in Twig, and how does it differ from `{% extends %}`-based inheritance?
  6. What is a reasonable justification for keeping business logic (like complex calculations, database queries, or validation) OUT of Twig templates, and instead computing that data in PHP controllers/services before passing it to the template?
  7. What is a Twig "filter", and how is it applied to a value?
  8. How does Twig typically handle template caching, and why does this matter for application performance?
  9. How does Twig handle conditional logic (if/else) within a template?
  10. What is the purpose of Twig's `{% set %}` tag?
  11. How does Twig handle looping over a collection (like an array of items) in a template?
  12. How do you deliberately output raw, unescaped HTML in a Twig template when auto-escaping would otherwise interfere (e.g. rendering trusted, pre-sanitized HTML content)?
Gaps to close?
Read the curated Twig notes — core concepts, patterns, interview prep.
Twig notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web