Preface: Nowadays, more and more people prefer to access the Internet, and more people have their own personal homepages. With the emergence of various automated software tools, making web pages easier and easier. However, because special effects are available everywhere, there are fewer and fewer innovative things. Maybe, someday, you will find that the counter on a website is exactly the same as your own. The more sophisticated the web page is. There are more and more things on the web page. Question:
- On the webpage, if I want to add a counter:
In the past, I went to the space provider to get a link or copy an address from other places. However, this is always done by someone else. well, you don't have much say, you can only find them one by one.
- On the webpage, I want to publish some information:
If the information is text, create a new page and add a link; Is data. create a new page and add a link: But if the data is updated frequently, or even every hour or minute, it may change. are you willing to keep changing and uploading data in front of your computer? (We are not a commercial website. no one is willing to burn money for you .) However, message boards, chat rooms, and forums cannot be handled by HTML or JAVASCRIPT alone.
To achieve more automatic control, you can use the CGI (Common Gateway Interface) program to implement these functions. Software Requirements: PHP: GD Library Configure a server that supports PHP. I use OmniHTTPd Professional For counters and real-time statistics and releases, we can use images to complete them. Output text in the image. In PHP, to create an image and display the dot content on it, follow these steps:
// The http header, telling the browser that this is a GIF image Header ("Content-type: image/gif "); // Do you want to draw a picture? Create a 400x300 color palette image $ Im = imagecreate (400,300 ); $ Black = imagecolorallocate ($ im, 0, 0, 0 ); // The default black background. // (The default value is the first defined color. If another color is defined before this line of code, the first color defined is the default background color .) $ Red = imagecolorallocate ($ im, 255, 0, 0 ); // Red. If the two lines are exchanged, you will find that the background is red and the text is black. $ String = "1234567890 "; // The characters to be drawn Imagestring ($ im, 12, 10, 10, $ string, $ red ); // Draw a string at (10, 10) Imagepng ($ im ); // Output in png format. you can also use imagejpeg ($ im); or magegif ($ im). However, if the latter version is higher than 1.6, it cannot be used. Imagedestroy ($ im ); // End, clear all occupied memory resources ?> In the preceding example, a 12-pound "400" image is drawn from a point (10, 10 ". Have you noticed that the image size is 251 bytes! You can also try other output formats. The image size depends on the number of non-background pixels in the image and the number of output pixels.However, there is a problem. You can use imagestring () to output the following information: Imagestring ($ im, 1, 0, 0, "abcdefghijklmnopqrstuvwxyz0123456789 ~! @ # $ % ^ & * () _ + {} |: "<>? [] ';,./", $ Red ); However, you cannot output Chinese characters correctly !!! Imagestring ($ im, 1, 0, 0, "ah", $ red ); What you see is by no means Chinese !! But garbled characters. PHP's default character set is UTF-8, while Simplified Chinese is GB2312. How can this problem be solved ?! To solve this problem, you can let PHP load the extension module php_iconv.dll (the extension name under UNIT is. SO). However, sometimes it may not work properly. Originally, I wanted to put a piece of test code up, but this time I was not successful. To avoid errors, I still don't put them on. However, the most critical thing is that if your space service provider disables the extension module or even disables the DL () function of the module, you can only follow the Chinese BYE-BYE. Fortunately, there are other methods. Character ING can be used to output characters in a pre-converted code table. However, you need a code table! Or, draw every Chinese point manually! How is it ?! Okay, come on, let's draw words together! To draw a word, you must first know how to draw it. Have you learned simple functions in junior high school? Do you want to draw a graph of a function? Calculate the coordinates of a point and connect the adjacent points. This method is called the plotting method. What we need to do is calculate as many points as possible and then display them in the corresponding coordinates. Have you ever heard of dot matrix printers and dot matrix Chinese characters? When outputting Chinese characters, they are represented by vertices. The function for displaying a color point on a coordinate is: Int imagesetpixel (resource image, int x, int y, int color) If I want to display a white point at coordinate (100,100), the following code is required:
Header ("Content-type: image/gif "); $ Image = imagecreate (400,300 ); $ Black = imagecolorallocate ($ image, 0, 0, 0 ); $ White = imagecolorallocate ($ image, 255,255,255); // defines white Imagesetpixel ($ image, 100,100, $ white ); Imagepng ($ image ); Imagedestroy ($ image ); ?> That is to say, we can use this function to output all vertices of a Chinese character.In the chs16.fon file, it is saved in the national standard location code table (GB-2312 of basic character set of Chinese character encoding used for national standard information exchange ). It is a dot matrix font for Chinese characters. (In WIN98, this file is in c: windowscommand. If you want to use it in a UNIX system, pay attention to the case. If not, you can find the link at the end of the article .) It is in the MSDOS era, but good things should still be used out. From chs16.fon, we can read the dot matrix data of Chinese characters. Each Chinese character consists of 16x16 points. Where the stroke goes, the vertex value is 1; otherwise, it is 0. each vertex occupies one position and every eight points constitute a byte. Therefore, a Chinese character requires (16x16 bytes 8 = 32) bytes. The following example is used to describe the representation of character lattice. Here, an 8x8 matrix is defined, and a letter C is displayed. the white square is represented by 0, and the black square is represented by 1, the code for these eight lines of images is:
Today, more and more people prefer to access the Internet, and more people have their own personal homepages. With the emergence of various automated software tools, making web pages easier and easier. But... |
|
|