SEO and Internet newsnews

File I/O & Php

Reading a File and updating it

Copy and paste the following code into your editor and run it (code comments are included).
If you want to see the live result, try it here (new window).

This example actually updates the file according to a date and a number; if the line contains the current date, it increments the number otherwise it adds another line with the current date.
Everyday a line is then added and a new counter is initiated.

The source code:

Notes:
- the file is automatically created if it does not exists (see writing into a file for more details);
- you need to have the necessary permissions to be able to write into a file on your server (see chmod on linux/unix).

You may wish to read additional materials from:
- http://www.php.net/manual/en/function.fgets.php
- http://www.php.net/sscanf

Comments

No comment yet, write the first now here or onto our webmaster forum
Add Url to Linkstraffic - Website traffic - Affiliates - Site Map