On Friday 22 November 2002 16:34, gamin wrote:
> Hello,
>
> im running Red Hat 7.2 with PHP 4.0.6. How would i go about writing to a
> file as the data is being written, not when the file is closed
>
> #!/usr/bin/php -q
> <?
>
> $fp=fopen('t', "a");
> if ($fp === false)
> die("could not open file");
>
> for($i=0; $i<10; $i++)
> {
> $time= date("D, Ymd. G:i:s");
> $time = $time."\n";
> $result = fwrite($fp, $time, strlen($time));
> if ($result == -1)
> die("error writing to file");
> // if ($condition) die; <-- in case this happens i would like to have the
> times outputted to the file 't'
> sleep(2);
> }
>
> fclose($fp);
>
> ?>
>
> i tried the above, while it is running but 't' comes up as a blank (seen
> using ls). How would i go about putting the contents in 't' when they are
> written to the file
I think you should try fclose() the file before you die!
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Mieux vaut tard que jamais!
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php