> For the complete documentation index, see [llms.txt](https://wplake.gitbook.io/advanced-views/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wplake.gitbook.io/advanced-views/features/smart-templates/php-templates.md).

# Smart PHP templates

*Layout* and *Post Selection* templates support vanilla PHP as a template engine. These templates are executed with [eval](https://www.php.net/manual/en/function.eval.php), so you can use any WordPress or PHP function inside them.

The default template uses built-in PHP short [opening tags](https://www.php.net/manual/en/language.basic-syntax.phptags.php) and [alternative control syntax](https://www.php.net/manual/en/control-structures.alternative-syntax.php) to make the template clearer and less verbose:

```php
<? foreach ($categories["value"] as $index => $term_item): ?>
    <a target="<?= esc_html($term_item["target"]); ?>" class="acf-view__categories-link" href="<?= esc_html($term_item["value"]); ?>">
        <?= esc_html($term_item["linkLabel"] ?: $term_item["title"]); ?>
    </a>
<? endforeach; ?>
```

The classic one for comparison:

```php
<?php foreach ($categories["value"] as $index => $term_item) { ?>
    <a target="<?php echo esc_html($term_item["target"]); ?>" class="acf-view__categories-link" href="<?php echo esc_html($term_item["value"]); ?>">
        <?php echo esc_html($term_item["linkLabel"] ?: $term_item["title"]); ?>
    </a>
<?php } ?>
```

You're totally free to use whatever version you prefer, or even mix them.

{% hint style="info" %}
Don't sacrifice the shorter alternative only for compatibility reasons.\
Advanced Views automatically replaces short tags with their full aliases before execution, so template rendering is completely independent of the [short tag ini-setting](https://www.php.net/manual/en/ini.core.php#ini.short-open-tag). &#x20;
{% endhint %}
