Manual of PHP

 
 
 

Web map

 
rim   rim
arrowReady frontarrow of Codesarrow simple Counting PHParrow for pages PHP

 

Simple book-keeper for pages PHP To print E-mail

We create a meter programmed in PHP, which takes the account of the impressions that have been realized on a web page, using a text file as a support.

I did a modification to the Script published in the article Writing of file with PHP, in which one teaches to write text files by means of PHP, touching the topics of reading and writing. The target is to take a count of the times that has visited a page.

I put the following script PHP at the end of the page, he will understand himself well if the article is read indicated earlier.

<?
$archivo = "contador.txt";
$contador = 0;

$fp = fopen ($archivo, "r");
$contador = fgets ($fp, 26);
fclose ($fp);

++ $contador;

$fp = fopen ($archivo, "w +");
fwrite ($fp, $contador, 26);
fclose ($fp);

I begin "This page it has been visited $contador times";
?>

Also, I created a file called "contador.txt" that I kept it in the same directory as the page. The above mentioned file was inicializado with a zero (0) as the only text.

It notices: if you have problems at the time of writing in a file, almost with all probability, it will be protected against writing. Or the file or the directory.

If you have your own servant you will have to modify the permissions of such a file or directiorio for yourselves. Nevertheless, if you are publishing in an accommodation hired in a provider you will have to find out of what mechanism it is necessary to start in this provider to obtain the permissions. In many cases there will exist a control panel where to modify these things, in other cases you will have to write to technical support so that they should do it to hand éllos or should say to you how to do it, if it is that it is possible.

With this it is already made a very simple, but very functional book-keeper.

 

 
Front
Chapters of the Manual of PHP
Introduction to PHP
Variables
My First Script PHP
Operators in PHP
Structures of Control
Functions in PHP
Code inclusion
Counterfoils (array)
Chains of Characters
Classes
Dates
Entry and Exit
Operations with Files
The language SQL and PHP
Connection with MySQL
Meetings
Forms with PHP
To practise in line
List of practices in line
FAQ
Frequent questions
Codes PHP
List of Codes PHP
Forums
Forums PHP
Other Manuals
Manuals of other languages
 
   
 
 
MySpaceScripts.info - Sitemap - Contact us - Sitemap - Contact us - Sitemap - Contact us

posizionamento Google , foam cup , Kiteboards , car.auto-moto-blog.co.uk , caza polonia , Conference Organizers Poland , bílé víno