8
luwii
8y

Spent about an hour wondering why my php code was showing in the browser window after submitting a form using Ajax. Found that I had start my php file with just <? And not <?php. Feeling dumb.

Comments
  • 1
    a while back, you could configure your web server to accept <? to be an open php tag.
  • 0
    @tomcentrate if it were automatic or could throw an error it would have saved me some time.
  • 1
    you can also go with <?= , it's like <?php echo
  • 1
    @luwii it's one of those options that is considered bad practices. The short tag <? could have errors when it comes to parsing xml.

    you can use the short tag echo <?= and that would be good practice .

    if you want to type <? to open your php tags though, look up the short_open_tag configuration in your php.ini
Add Comment