# Curious question about php tags

**URL:** <https://forum.getkirby.com/t/curious-question-about-php-tags/16782>\
**Category:** Questions\
**Tags:** v3\
**Created:** [January 5, 2020, 6:44pm UTC](https://forum.getkirby.com/t/curious-question-about-php-tags/16782 "2020-01-05T18:44:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![julianlengfelder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/julianlengfelder/32/7864_2.png) [@julianlengfelder](https://forum.getkirby.com/u/julianlengfelder)\
**Post date:** [January 5, 2020, 6:44pm UTC](https://forum.getkirby.com/t/curious-question-about-php-tags/16782/1 "2020-01-05T18:44:39Z")

</div>

Hi there, been a long time since I last used php and I just stumbled upon a curious question.  
This code produces an ‘unexpected error’:

```
<?= if ($hero_image = $page->hero_img()->toFile()): ?>
<img src="<?= $hero_image->url() ?>" srcset="<?= $page->hero_img()->toFile()->srcset([300, 800, 1024])?>" alt="" />
<?= endif ?>

```

This works:

```
<?php if ($hero_image = $page->hero_img()->toFile()): ?>
<img src="<?= $hero_image->url() ?>" srcset="<?= $page->hero_img()->toFile()->srcset([300, 800, 1024])?>" alt="" />
<?php endif ?>

```

Why is this the case? To my understanding short tags were ok to use by now. My local dev environment is running on php 7.3.8

I feel like I am missing something and would be very happy for some enlightenment 🙈

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [January 5, 2020, 6:57pm UTC](https://forum.getkirby.com/t/curious-question-about-php-tags/16782/2 "2020-01-05T18:57:23Z")

</div>

> [@julianlengfelder](#):
>
> \<?=

This is the short echo tag, which is the same as the long form `<?php echo`. Using that with an if-statement doesn’t make sense.

Contrary to the short echo tag, PHP short tags `<?` as in `<? if ($this == $that) { //... ; }?>`, however, should be avoided.

---

<div class="post-metadata">

**Author:** ![julianlengfelder](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/julianlengfelder/32/7864_2.png) [@julianlengfelder](https://forum.getkirby.com/u/julianlengfelder)\
**Post date:** [January 5, 2020, 7:31pm UTC](https://forum.getkirby.com/t/curious-question-about-php-tags/16782/3 "2020-01-05T19:31:03Z")

</div>

Thank you very much for explaining! I probably should read up on basics again.
