I’m using PHP to process some files (run regexp, replace etc) and I’ve noticed that after processing, there’s always a newline at the beginning of all the files I’ve processed. I’ve narrowed it down to these few lines:
#!/usr/bin/php
<?php
$test = file('php://stdin');
file_put_contents('php://stdout',$test);
?>
If you save this and pipe some text through it, you’ll notice there’s a newline at the beginning of the output. Where is it coming from and how do I get rid of it? Thanks!
PS: PHP version is: PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00)
Erm, it’s between the shebang line and the
<?php. I think you can figure out easily enough how to remove it.