overwrite to file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonny T

    overwrite to file

    Hi!,
    I a php noob so sorry if this is a stupid question,
    I have a little code that puts some data in a file
    which works very well.
    I want to instead of append to the file I want
    to overwrite the contents of it.

    ??

    -------------------existing code-------------------
    <?php
    $filename = "justatest.txt" ;
    $output = "SOME_DATA_HERE ";
    $filehandle = fopen($filename , 'a');
    fwrite($filehan dle, $output);
    fclose($filehan dle);
    ?>
  • Dennis Biletsky

    #2
    Re: overwrite to file


    "Jonny T" <jonnyt@someisp 3.com> ???????/???????? ? ???????? ?????????:
    news:c4tvmt$b1$ 1@titan.btinter net.com...[color=blue]
    > Hi!,
    > I a php noob so sorry if this is a stupid question,
    > I have a little code that puts some data in a file
    > which works very well.
    > I want to instead of append to the file I want
    > to overwrite the contents of it.
    >
    > ??
    >
    > -------------------existing code-------------------
    > <?php
    > $filename = "justatest.txt" ;
    > $output = "SOME_DATA_HERE ";
    > $filehandle = fopen($filename , 'a');
    > fwrite($filehan dle, $output);
    > fclose($filehan dle);
    > ?>[/color]



    "w" or "w+" istead of "a"


    Comment

    • Niall Kavanagh

      #3
      Re: overwrite to file

      In comp.lang.php Jonny T <jonnyt@someisp 3.com> wrote:
      [color=blue]
      > I want to instead of append to the file I want
      > to overwrite the contents of it.[/color]
      [color=blue]
      > $filehandle = fopen($filename , 'a');[/color]

      $filehandle = fopen($filename , 'w');



      --
      niall

      Comment

      • Davor

        #4
        Re: overwrite to file

        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        On Tue, 6 Apr 2004 10:10:37 +0000 (UTC)
        Jonny T <jonnyt@someisp 3.com> wrote:
        [color=blue]
        > <?php
        > $filename = "justatest.txt" ;
        > $output = "SOME_DATA_HERE ";
        > $filehandle = fopen($filename , 'a');
        > fwrite($filehan dle, $output);
        > fclose($filehan dle);[/color]

        Let the code look like this

        $filename = "justatest.txt" ;
        $output = "SOME_DATA_HERE ";
        $filehandle = fopen($filename , 'w');
        fwrite($filehan dle, $output);
        fclose($filehan dle);
        - --
        Kamratligen,
        Davor


        My GPG-key can be found at

        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.2.2 (FreeBSD)

        iD8DBQFAz5uNhCu ya7YOfA4RAqFvAJ 9e78B5F1RS9gV4D/EFjMHhCd5RNQCfW hTi
        spKr4AfhBHf1D/JRKA1/Gc8=
        =takd
        -----END PGP SIGNATURE-----

        Comment

        Working...