Michael A Heap

PHP Short Tags

September 3, 2009 Code, PHPNo Responses on this article

After reading that PHP6 might drop support for short tags, I decided to update my main Codeigniter project to use full php tags. I didn't want to have to go through each file and update them by hand, so I set about automating it. I managed to do it using grep, awk and perl, and a lot of trial and error.

This is probably far from the best way to do it, but it works for me :)

grep -lr '<?=' * | xargs perl -i -p -e 's/<\?=/<\?php echo /g;'
grep -r '<?' * | grep -v '<?php' | awk -F":" '{ print $1 }' | xargs perl -p -i -e 's/<\?(?!php)/<\?php/g;'

Related posts:

  1. Codeigniter Setup
  2. Custom Wordpress Taxonomies
  3. Parsing Tables In Text Files

Tags: , , , , , ,
« »

Leave a Reply