A PHP block is started with the tag <?php. However, there is also an alternative known as a "short open tag" which is to only use <?
The problem with using short open tags is that they conflict with xml parsers and for that reason, support for short open tags has to be enabled. By default, it's disabled and enabling deprecated features may be impossible if hosts don't allow it.
Every so often you may come upon a code base that was written using short open tags.
Often people are first confronted with this problem when they have a legacy code base, and either move it to a new server or upgrade php only to find that the site is spewing errors and no longer functional. In a worse case scenario portions of your php code will be plainly visible to end users due to the fact that the php parser is no longer parsing those blocks and simply returning them as html text.
Secondarily, there is at least one tool available with the name of phptags tag tidier that will parse and edit your source files. From the looks of it, it's an open source, php based package that uses some scripting to make it into a *nix command line utility. It looks pretty solid and seems to be maintained and relatively current, but I haven't tried it out personally.
If you are already having to do a lot of other edits, aren't finding the tool compatible, or just aren't entirely comfortable trusting a tool not to mangle your source files, there is always the search and replace feature in your code editor.
Without regular expression support in your editor, this is likely to be a slow and error-prone process, especially if the short open tags are intermixed with the normal tags, or the allowable alternative syntax tags like <?= You'll also be likely to screw up your formatting, requiring you to fix things manually.
A regex Search and replace solution
This simple search and replace pair should do the trick:
Without going too much into regex, this utilizes 2 capturing groups, which is why I used parens around the two sections. Inside the first capturing group (), you actually find the short tag with <\?. A question mark is a special regex character which is why in regex, when you need to find a literal question mark, you have to escape it first with the backslash.
So as not to also find <?phpor <?=, you only want to match <? when it is followed by whitespace.
The 2nd capturing group uses a built in regex character class (\s) to match any existing whitespace. You need to do this because it is not uncommon for a block to be immediately followed by a carriage return, however it might also be followed by a space if it's a small inline php block intermixed within some html code.
The reason we capture the whitespace in its own group, is that when we replace the short open tag, we want to leave the whitespace alone. That way you aren't going to screw up the original formatting that existed before your replacement.
In the replacement we change our <? to <?php, but then immediately restore whatever whitespace we originally matched using the $2
Double check the regex replacement syntax within your editor's documentation. The way you specify a captured portion in a replacement may be different, but just about all text editors that support regex also seem to support this capability in some fashion.
Using your editor's search and replace will allow you to test out this regex and gain comfort, or even step through the replacements, and of course if something goes horribly wrong, you will be able to undo those changes. Once you're comfortable with the stability of this, replacement of short open tags in legacy code should be a simple and relatively painless operation.