convert php short tag to normal php tag – will fix the xml tag and php shortag conflict in same file


I was facing a problem with PHP short tag and XML tag in my web application.
In my PHP file I put XML coed and php code in same file. So when it complies, its throwing error because of XML tag like ” <?xml ” .

So I came up with a solution to fix this.

I turned of PHP short tag in my php.ini and restart the web server.

And run the following shell script, which will convert all PHP short tag to normal PHP tag.

if [ -z "$1" ]
 echo "No argument supplied"

find $1 -type f -exec sed -i 's/<?xml/?<xml/g' {} +

find $1 -type f -exec sed -i 's/<?php/<?/g' {} +

find $1 -type f -exec sed -i 's/<?/<?php/g' {} +

find $1 -type f -exec sed -i 's/?<xml/<?xml/g' {} +