Replace PHP short open tags with full form in all ‘.php’ files using one command

Nowdays, In the latest versions of web servers, The PHP short open tags are diabled by default, Although we can able to enable it in the ‘php.ini’ file, Some of the shared hosting servers may be diabled that systax and you have to migrate your code to the standard syntax…

So it is good to avoid the short tag and follow standard tag from now on while coding. But to migrate the old codes, Here is a simple command line for linux which migrates the code in all the ‘.php’ files in the current directory to the standard syntax.

find . -iname '*.php' -type f -print0 |xargs -0 sed -i -e 's/<? /<?php /g' -e 's/<?\/\//<?php \/\//g' -e 's/<?\/\*/<?php \/\*/g' -e 's/<?\=/<?php echo/g'    

The above command convers,

"<?" to "<?php"     
"<?=" to "<?php echo"
"<?//" to "<?php //"
"<?/*" to "<?php /*"