phptags is a simple commandline tool to tidy up open and close tags in PHP scripts. It can rewrite <?php open tags into long and short form, add or remove trailing ?> close tags, and strip leading or trailing whitespace (or UTF-8 BOM).
- phptags --whitespace *.php
- Fixes surrounding whitespace issues for all *.php scripts in current directory.
- phptags --long ./templates/
- Rewrites all short <? into long <?php tags. Recursively works on a directory tree.
- phptags --short --all --tokenizer *.php
- Uses tokenizer mode for rewrites, turns all long open tags into short ones.
- phptags --verbose --closed --whitespace --warn --short *.php scripts/ templates/ config/*.php
- Adds missing ?> close tags, warns about and fixes whitespaces, also shortens <php echo tags into <?= (but not others), is verbose, and scans directories and a given list of *.php files.
- phptags -v -u -w -W -a .
- Short options for verbose, unclosed, whitespace, warn, shortall. Dives into all current subdirs.