PHP One-liners
I'm starting a collection of one-line PHP programs that I've used on the command line.
This removes trailing white space from a DOS file:
C:\>php -r "foreach (file($argv[1]) as $l) {print rtrim($l).chr(13).chr(10);}" user.module > user.module.trimedThis little gem escapes code for inclusion in HTML. The invocation uses UNIX's cat utility, on Widows you could use type:
$ cat test.php | php -r "print htmlentities(file_get_contents('php://stdin'));"






