WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1Accespted Counter Fri Jan 21, 2011 6:39 pm

Unknown Data

Unknown Data
Registered Member
Registered Member
Counter
Learn PHP - Part 6


We are now starting creating our counter. It's actually very simple. Try take a look at the fully source and I'll later explain it to you.
Code:
<?php
$count = file("visits.txt");
$count_gl = $count[0];
$new_count = ++$count_gl;
$data = fopen("visits.txt","w");
$write = fwrite($data,$new_count);
fclose($data);
echo "We have reached <b>$new_count</b> visits!";
?>
See that wasn't so much? Now let's take a look at the code.

$count = file("visits.txt");
Here are we reading our file and the content is saved in a array.

$count_gl = $count[0];
The first line in our arrays is saved in the variable count_gl

$new_count = ++$count_gl;
After that are we counting our variable count_gl up with one.

$data = fopen("visits.txt","w");
Here are we opening up for our data. The file visits.txt is opened in a writting statemnt (w).

$write = fwrite($data,$new_count);
Here is the new value written.

fclose($data);
When we are finish with the data, are we then closing it.

echo
Writting some content like HTML, CSS etc. and the status for the counter.

That was actually just it. Hope you've learned what you need to learn, about some simple things in the PHP library.

Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.

http://woops.dk

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum