Posted by The Natural Philosopher on 11/21/07 22:42
jools@by.com wrote:
> I'm having trouble modifying some code written by someone else.
> The code is very dense and obscure but does work fine. However I need to
> insert a block of my own and I've hit what I assume is a buffering
> problem.(If there's another answer I'd be grateful ...)
>
> The problem is PHP is refusing to do things in the correct sequence.
>
> I've tried all the variations of flushing I can think of without success.
>
> Can anyone suggest how I can force PHP to do this task in the correct
> sequence please?
>
> Thanks
> -jools-
>
> Using PHP 5.1
> Centos Linux V4
> Apache 2 server
>
> I need to do this:
> ------------------
>
> 1. I create a text file on the fly inside a folder
> 2. I output some lines from that text file -(May include some HTML such
> as a form but is not activated/posted) using echo or print
> 3. I delete the text file from the drive
>
> The sequence that occurs however is not 1 2 3
> but 1 3 2
> And I get an error because the file can't be found by event 2
>
I had a similar experience. PHP does NOT flush a file to disk it seems
until the program exits, or you do in my case a COPY() on it.
My workaround was to create the 'file'
copy the 'file'
do a Mysql LOAD on it
unlink the original 'file' and the copy file..
> OK I thought - I remember something about ob_flush so I tried
>
> 1
> 2
> ob_flush(); // or a variant such as ob_end_flush()
> 3
>
> And still I get 1 3 2 instead of 1 2 3
>
> I've tried ob_start
> i.e
>
> 1
> ob_start()
> 2
> ob_end_flush()
> 3
> but no luck
>
> I've tried multiple ob_flush()'s one after the other - no luck
>
> -----------------------------
>
>
Did you fclose() the file first?
>
[Back to original message]
|