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

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

 



Jochem Maas schreef:

...


indeed ... I tested it and it works on my server too. my code is no different
to yours with regard to the context of the problem. so what's going on.

I think (I know) I forgot to mention one tiny little detail.
the whole 'include' code occurs in a script that forks itself ...
the script forks itself a number of times and each child then performs
the include.

so I tested the fork issue with your script ... it still bloody works,
(see the for loop below) so it's something else ... I thought it might
be the difference between using ob_get_clean() and ob_get_contents()+ob_end_clean()
but that doesn't seem to be it either.

the worse thing is my script has just stopped outputting the shebang lines of the included script(s) ... oh well ... the problem is solved, dunno how, dunno why,

situations like these I'd rather the problem didn't go away .. I prefer to know
wtf happened!

wtf happened was I was looking at the wrong output. I changed my code to
be as much like your test code as possible (to the point that I now
use a function to perform the buffering and 'include' and returning output) ... 	
the output buffering is not working at all.

I've had enough - /dev/null meet script output, output meet /dev/null


----<test.php>----
#!/usr/bin/php
<?php
    echo "arse\n";

    for ($i = 0; $i < 3; $i++) {
        $pid  = pcntl_fork();
        if ($pid == 0) {
                echo Inc('testinc.php');
                exit;
        }
    }


    function & Inc($f)
    {
        ob_start();
        @include($f);
        $content = ob_get_contents();
        ob_end_clean();
        if (substr($content, 0, 2) == '#!')
        {
            $content = substr($content, strpos($content, "\n")+1);
        }
        return $content;
    }
----</test.php>----

----<testinc.php>----
#!/usr/bin/php
<?php
    echo "testinc\n";
----</testinc.php>----

----<output>----
Stut@Giles:~$ ./test.php
arse
testinc
----</output>----

-Stut



--
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