Regular expression to find <? instead of <?php

So I was getting “Parse Error: syntax error, unexpected $end filename on line linenum” In a wordpress plugin. The file was working correctly on my live server but not on xampp and the line number was the last line of the file. A bit of googling searching pointed me to the issue being a mixture of <? and <?php.

So if you come across the issue, and don’t want to manually search through your 2000 line file to find the offending tag, the following regular expression will find those naughty <? tags
<?[^p]

About Carly (Admin)

I'm a multimedia developer based in Brisbane. I work for an elearning firm and code my own projects in the wee small hours between eating, sleeping and working.
This entry was posted in php, Programming and tagged . Bookmark the permalink.

Leave a Reply