Batch script to replace PHP short open tags with <?php

前端 未结 13 1873
轻奢々
轻奢々 2020-11-30 01:49

I have a large collection of php files written over the years and I need to properly replace all the short open tags into proper explicit open tags.

change \         


        
13条回答
  •  半阙折子戏
    2020-11-30 02:54

    This is a utility I wrote that converts PHP source that contains short open tags and replaces them with long tags.

    • https://github.com/danorton/php_replace_short_tags

    i.e. it converts code like this:

      
      
    

    To this

      
      
    

    The --skip-echo-tags option will cause it to skip tags and only replace tags.

    It’s written as a PHP-CLI script and needs the CLI php.ini file to be set to permit short short open tags. That’s the default setting for PHP 5.3.0 and earlier, but it might not always remain so. (The script simply won’t change anything if the setting isn’t enabled.)

提交回复
热议问题