Joined August 2014
·

Ben J

Australia
·
·

Thanks a lot for getting the initial work done, however it will break some code or not catch all the shorthand if any of the following are met:

  • you already have the newer format. aka "<?php"
  • if tab or newline is used directly after the shorthand

you will need regex lookahead, which sadly plain old sed doesn't support, you'll need ssed for this.

a quick install will fix this though and we can use perl like regexing.

apt-get install ssed

now our pattern

find . -iname '*.php' -type f -print0 | xargs -0 ssed -i -R -e 's/<\?\=/<?php echo /g' -e 's/<\?(?!php)(?!=)/<\?php /g'

This will cover

"<?=" to "<?php echo "
"<?" to "<?php " .... but not "<?php"
Achievements
1 Karma
0 Total ProTip Views