Not a Member Yet,
Click here to Register

ID: 55
Viewed: 5107
Added: Dec 09, 2001
Version:
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

A very short way to read a flat file and write to a flat file. this is similiar to having a counter on your site.

<!---Head--->
none

<!---Body--->


 <?
// open the file in read mode only
$fileread = fopen("file.txt", "r")Or die("Can't open file");
// Since fread() retu\r\ns a string value, the last number
// of access read from the data file needs to be
//converted to an interger value (int) reading 10
//bytes from the data file.
$data = (int) fread($fileread, 10);
// closes the file
fclose($fileread);
// adds 1 to the value
$data++;
// open the file again in write access mode
$fileread = fopen("file.txt", "w") Or die("Can't open file");
// writes the data to the file
fwrite($fileread,$data);
fclose($fileread);
?>


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!