PHP implementation code and annotations for graphical display IP address _php tutorial

Source: Internet
Author: User
Use graphical display IP, file sunip.php

Copy the Code code as follows:
Header ("Content-type:image/gif");
$im = Imagecreate (130,15);
$background _color = imagecolorallocate ($im, 255, 255, 255);
Unset ($IP);
if ($_server[' http_client_ip ']) {
$ip =$_server[' http_client_ip '];
} else if ($_server[' http_x_forwarded_for ']) {
$ip =$_server[' http_x_forwarded_for '];
} else{
$ip =$_server[' remote_addr '];
}//Www.jbxue.com
$col = imagecolorallocate ($im, 0, 51, 102);
Imagestring ($im, 3, 5, 1, $ip, $col);
Imagegif ($im);
Imagedestroy ($im);
?>

1.

2. Header ("Content-type:image/gif");
The second line declares that the browser header output is GIF graphics
3. $im = Imagecreate (130,15);
Create a graphic imagecreate (130,15) in brackets 130, 15 for width and height, respectively
4. $background _color = imagecolorallocate ($im, 255, 255, 255);
Set the background color imagecolorallocate to assign a color to a picture ($im, 255, 255, 255) IM represents the 10 binary characters of the color table ffffff that represent the 3 255 behind the new shape mentioned earlier
5. unset ($IP);
Useless
6.if ($_server[' http_client_ip ')} {
$ip =$_server[' http_client_ip '];
} else if ($_server[' http_x_forwarded_for ']) {
$ip =$_server[' http_x_forwarded_for '];
} else{
$ip =$_server[' remote_addr '];
}
If $_server[' http_client_ip ' can be used then using $_server[' Http_client_ip ') is similar to judging this paragraph to be compatible with a variety of server settings
7. $col = Imagecolorallocate ($im, 0, 51, 102);
Define text color
8. Imagestring ($im, 3, 5, 1, $ip, $col);
The acquired IP is drawn onto the newly created canvas imagestring ($im, 3, 5, 1, $ip, $col); Represents imagestring (graphic representation, character size 1-5,x coordinates, y-coordinate, output IP, color), respectively
9. Imagegif ($im);
Output GIF Graphics
Imagedestroy ($im);
Freeing memory
?>.
End of program

http://www.bkjia.com/PHPjc/718606.html www.bkjia.com true http://www.bkjia.com/PHPjc/718606.html techarticle using the graphical display IP, the file sunip.php copy code code is as follows:? PHP header ("Content-type:image/gif"); $im = Imagecreate (130,15); $background _ color = Imagecolorallocate ($im, 2 ...

  • 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.