By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,050 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,050 IT Pros & Developers. It's quick & easy.

overwrite to file

P: n/a
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($filehandle, $output);
fclose($filehandle);
?>
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Jonny T" <jo****@someisp3.com> ???????/???????? ? ???????? ?????????:
news:c4*********@titan.btinternet.com...
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($filehandle, $output);
fclose($filehandle);
?>


http://php.net/manual/en/function.fopen.php

"w" or "w+" istead of "a"
Jul 17 '05 #2

P: n/a
In comp.lang.php Jonny T <jo****@someisp3.com> wrote:
I want to instead of append to the file I want
to overwrite the contents of it. $filehandle = fopen($filename, 'a');


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

http://www.php.net/manual/en/function.fopen.php

--
niall
Jul 17 '05 #3

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 6 Apr 2004 10:10:37 +0000 (UTC)
Jonny T <jo****@someisp3.com> wrote:
<?php
$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'a');
fwrite($filehandle, $output);
fclose($filehandle);


Let the code look like this

$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'w');
fwrite($filehandle, $output);
fclose($filehandle);
- --
Kamratligen,
Davor
My GPG-key can be found at
http://blupp.net/~davor/davor.key
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFAz5uNhCuya7YOfA4RAqFvAJ9e78B5F1RS9gV4D/EFjMHhCd5RNQCfWhTi
spKr4AfhBHf1D/JRKA1/Gc8=
=takd
-----END PGP SIGNATURE-----
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.