Today I was updating a bunch of .php files transferred from old hosting to a new platform. Many of them had old-style tags denoting the beginning of php block.
To quickly replace <? with <?php I used the following command:
find . -type f ! -path '*/.svn/*' \( -name '*.php' \) -print0 | xargs -0 sed -E -e '/<\?[[:space:]]/ s/<\?([[:space:]])/<?php\1/g' -e 's/<\?=[[:space:]]*((([^?])|(\?+[^?>]))+[^[:space:]])[[:space:]]*\?>/<?php echo(\1); ?>/g' -e '/<\?$/ s/<\?$/<?php/g' -e '/<\?[^[:alpha:]]/ s/<\?([^[:alpha:]])/<?php \1/g' -i '.bak'