Re: Re: [SOLVEDish] Re: [PHP] output buffering in CLI script.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Rixham schreef:
how's this?

#!/usr/bin/php
<?php
class trimshebang {
  function filter($in, $out, &$consumed, $closing)
  {
    while ($bucket = stream_bucket_make_writeable($in)) {
      $bucket->data = ltrim($bucket->data,"#!/usr/bin/php\n");
      $consumed += $bucket->datalen;
      stream_bucket_append($out, $bucket);
    }
    return PSFS_PASS_ON;
  }
}

stream_filter_register("trim.shebang", "trimshebang");
include "php://filter/read=trim.shebang/resource=/path/to/include.php";
?>

bit more graceful ;)

it's sick, I like it, nice example of streams filtering while your at it.
I learned something! it also works in so far that the shebang line is no longer
output but the output buffering in *my* script(s) doesn't work, whilst the same
construction does work in Stut's test scripts (although whilst playing with
his script I did manage to bork ik so that the output buffering *doesn't* work
there anymore ... how I did that I can't fathom)

anyway - they problem has been nicely shoved under the carpet. apart from
the shebang lines the script don't ever output anything anyway but rather
log to files ... a simple redirect output to /dev/null in the command line
that is used to run the 'master' script will take care of any spurious cruft
ending up on screen.

thanks to everyone for their input regarding my output! :-)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux