What are PHP tags and what are the different types?

Beginner

Answer

PHP tags are used to embed PHP code in HTML. The types are:

  • Standard tags: <?php ... ?> (recommended and always available)
  • Short echo tags: <?= ... ?> (for outputting, always enabled in PHP 5.4+)
  • Short tags: <? ... ?> (not recommended, requires short_open_tag enabled)
  • ASP tags: <% ... %> (removed in PHP 7.0)

Standard tags are recommended for maximum compatibility and clarity.