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,348
  • 2
  • 18
  • 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

3 Answers3

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
  • 24,203
  • 9
  • 60
  • 84
Nicholas Johnson
  • 1,012
  • 2
  • 12
  • 35
0

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,348
  • 2
  • 18
  • 27
0

I have the same problem but I would like all scripts to have <?php instead of allowing <? modifying the php.ini

I use visual studio code but it works for any editor (sublime, etc.). First I make a change in the files and replace <? by <?php At that time I will have the ones that had <? correct and I will have the ones with <?php as <?phpphp

The next thing is to replace <?phpphp with <?php and that's it.

Steven
  • 1,996
  • 3
  • 22
  • 33
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32068383) – IT goldman Jun 25 '22 at 23:11