0

I have a project I am moving that has many files, many of which were opened with <? rather than <?php

I'm trying to globally replace <? with <?php in text wrangler, sublime text, and phpstorm, but none seem to want to grab just the <? (using the whole word check box).

I'll take any approach, but i do like the GUI for this one so I can inspect the search/replace results.

As an FYI, I am migrating a codebase. On the new server I am getting a raw dump of the php file for files opened with <?. stupid. Replacing with <?php fixes the issue. There are probably other ways to fix the issue.

Iannazzi
  • 1,282
  • 2
  • 17
  • 27
  • This appears to be a question on using text editors, so I voted to close it as off-topic. *However*, you are trying to use them for programming, so I think I should comment that the whole word option might be what is preventing the text editors you have tried from working as you intend. And your question seems to be cut off just at the – Andrew Morton Jan 23 '16 at 20:35
  • ...oh, and if you have a regex option for search-and-replace in those editors, you will need to have it switched *off*. – Andrew Morton Jan 23 '16 at 20:55
  • Make sure you have version control (e.g. git) setup so that you can diff/inspect the results. – minghan Jan 23 '16 at 21:03

2 Answers2

1

The easiest way for me to solve this was simply to enable short tags, as described here...

How to enable PHP short tags?

Put the following line in your PHP.ini:

short_open_tag=On
Community
  • 1
  • 1
Iannazzi
  • 1,282
  • 2
  • 17
  • 27
0

This one is quite simple, as it is easy. I am assuming that your text editor supports Find/Find & Replace. If it doesn't go download and install Notepad ++ and hold CTRL + F and that'll bring up the find menu. After that, open all of the relevant PHP files. Navigate to the find & replace tab in the CTRL menu. From there enter <? and <?php into the two boxes, check all documents and hit replace all.

Andrew Morton
  • 22,953
  • 9
  • 55
  • 76
Nicholas Johnson
  • 932
  • 2
  • 11
  • 33