2

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)
miken32
  • 42,008
  • 16
  • 111
  • 154
DHz
  • 97
  • 8
  • short_open_tag dont affect = since PHP 5.4. What are the parse errors from Homestead or Valet? – leoap Nov 02 '16 at 21:48
  • @leo_ap One of the parse errors I have received is the unexpected end of file, which is present when the php tag is opened using `` rather than ` – DHz Nov 02 '16 at 21:52
  • @RyanVincent This type of answer is never helpful. DHz obviosuly has a lagecy project on his hands and replacing the short tags might not be an option. – Jakub Judas Nov 02 '16 at 21:53
  • 1
    A silly question, but did you restart the server? – Pankucins Nov 02 '16 at 21:54
  • [Ryan Vincent](http://stackoverflow.com/users/3184785/ryan-vincent) if I were to run the site using a server running – DHz Nov 02 '16 at 21:54
  • Is there at least a space after the short tag? I have seen PHP not parse files because there was something like /*comment*/ – Jakub Judas Nov 02 '16 at 21:55
  • [Pankucins](http://stackoverflow.com/users/1234502/pankucins) Yes! (... I think so) I've restarted the php & apache2 services on Ubuntu.. which I believe should do the trick? – DHz Nov 02 '16 at 21:56
  • [Jakub](http://stackoverflow.com/users/5341053/jakub-judas) Even with a space it still does not parse. specifically.. } ?> However, once that error is fixed the rest of the PHP is output as plain text. – DHz Nov 02 '16 at 21:57
  • 1
    @RyanVincent PHP 7 is still supposed to support the short tag - only the <% tag was removed – Jakub Judas Nov 02 '16 at 22:03
  • [Ryan Vincent](http://stackoverflow.com/users/3184785/ryan-vincent) [Jakub Judas](http://stackoverflow.com/users/5341053/jakub-judas) - It's starting to make more sense as to why PHP cannot parse the tags now. I'll try spinning up a VM running PHP 5.3. Thanks for the help – DHz Nov 02 '16 at 22:04
  • @DHz if you replace the offending short tag in one file with a normal tag, does the code run? It could also be some other thing that no longer parses well in php 7 – Jakub Judas Nov 02 '16 at 22:05

1 Answers1

1

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

DHz
  • 97
  • 8