Re: Anyone have a tool/script to convert <? to <?php (but not <?=)

From: Date: Sat, 15 Feb 2014 01:00:05 +0000
Subject: Re: Anyone have a tool/script to convert <? to <?php (but not <?=)
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-322883@lists.php.net to get a copy of this message
Multiple regular expressions would be the way to go then. Do the first one I sent (changing to <?phpcommand) then run another matching something like <?php\w and replace with <?php $1<-- that's a space --jk On 14 Feb 2014, at 14:55, Daevid Vincent wrote:
No I don’t want to change <? if ($foo) ?> To <?php if ($foo) ?> That's ugly. And loses any block/indentations which help in readability. What I want is to ONLY add a space in the case there is '<?command' so it becomes '<?php command' and not breaking it with '<?phpcommand' ... adding a space all the time makes other formatting ugly then as '<? command' becomes '<? command' with two spaces. I realize this may seem trivially cosmetic; I was just asking if that lookahead stuff can be applied to the replace portion as well somehow? Or maybe I run two separate regex matches on the parsed file to handle both cases since I intend to write a little .php script that will traverse a directory recursively to hit all the *.php files and re-write them (once this is tested of course)


« previous php.general (#322883) next »