Session on setting up a PHP personal website (1)

Source: Internet
Author: User

Here, I would like to share with you my personal website construction experience. Sorry, please correct me!
1. Edit the debugging environment
Win98 local editing and debugging, cool? First, run OmniHTTPd proffesinal v2.06 and install php4beta3. If you know HTML better, editplus is recommended! Otherwise, you have to use Dreamweaver first. Connect to the database? Fortunately, MySQL also has the for Win32 version.
2. First, a counter
Your counters are always better than others! Current counters Source code It will always take a long time to refresh, and you will not be able to deceive yourself. However, let's analyze how it works first. Below is an example of a simple counter:
<PHP $ countfile = "count.txt ";
If (file_exists ($ countfile ))
{$ Fp = fopen ($ countfile, "R + ");
$ COUNT = fgets ($ FP, 5); $ count + = 1; rewind ($ FP );
Fputs ($ FP, $ count, 5 );
Fclose ($ FP );
}
Else
{
$ Fp = fopen ($ countfile, "W ");

$ COUNT = "1 ";

Fputs ($ FP, $ count, 5 );

Fclose ($ FP );

};

?>

This counter has an external number, which is called "long _ ^" when it is flushed. So how can we make the counter more authentic? PhP4 gives us a simple way to use session-level variables. When you enter the page, first check whether the count in the session exists and is equal to the value you want. Otherwise, the count is equal to the first, and then call the count process. After the session ends, you can say to count: byebye!

But what should I do if it is not PhP4? Do you still remember the cookie? We can assume that a person's request to your web page does not belong to a new user within 15 minutes (or within another period of time), so that you can make a counting process in Inc, when each page is referenced, the visitor sends the access time to the cookie upon first entry. When each page is accessed, the last cookie access time value will be checked. If the difference is greater than 15 minutes, it will be counted; otherwise, the time will be refreshed. (You don't even know how to use cookies, do you? Haha, we recommend a book "php core programming", which is in Tsinghua version. It is enough to query functions. Every function has an example:-d)

However, the counter just now has no appearance at all. It is estimated that you are not satisfied. Change the image. Make a set of 0.jpg, 1.jpg ...... 9. jpg. Didn't I just read a string? After the combined outputs, the graphic counter will not come out?

Well, the counters for individual users are already perfect.

To be continued...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.