Search code examples
phpcodeigniterubuntuhomesteadphp-shorttags

How to enable PHP short_open_tag


For unknown reasons my PHP sites cannot parse PHP short open tags

e.g. <? rather than <?php. I believe this also affects the <?= tag, although I have not come across any issues directly relating to that in my project.

I have tried enabling short_open_tag in php.ini whilst using Homestead and Valet however I am still receiving parse errors.

Any help on how I can enable the use of PHP short open tags would be much appreciated as I am unable to perform a bulk find and replace.

Creating a basic php file and running ini_get("short_open_tag") returns 1. Which I presume means the setting is enabled? Yet a site running on valet still cannot parse shorthand tags.

NOTE: I do not want to use shorthand tags, however, this is a legacy project.

Useful information:

  • Ubuntu: 16.04 LTS
  • PHP: PHP 7.0.8-0ubuntu0.16.04.3 (CLI) -- EDIT: (Homestead vm was running PHP 5.6)
  • Vagrant: Vagrant 1.7.4
  • Laravel Valet: version 1.1.16
  • Apache: Server version: Apache/2.4.18 (Ubuntu)

Solution

  • Update: This was resolved by switching to a Scotch Box vagrant box. Thanks all.