PHP to implement graphics display IP address code and comments

Source: Internet
Author: User
Tags comments

  This article mainly introduces the implementation of PHP graphical display IP address, the need for friends can refer to the

Using graphics to display IP, the file sunip.php  code is as follows: <?php  header ("Content-type:image/gif");  $im = Imagecreate (130,15); nbsp $background _color = imagecolorallocate ($im, 255, 255, 255);  unset ($IP);  if ($_server[' http_client_ip ']) {& nbsp $ip =$_server[' http_client_ip ']; } else if ($_server[' http_x_forwarded_for ']) {  $ip =$_server[' HTTP_X_ Forwarded_for ']; } else{  $ip =$_server[' remote_addr ']; }// $col = Imagecolorallocate ($ IM, 0, Wuyi, 102);  imagestring ($im, 3, 5, 1, $ip, $col);  imagegif ($im);  Imagedestroy ($im); ?> &N Bsp   1. <?php    2. Header ("Content-type:image/gif");  the second line declares the browser header output to GIF graphics   3. $im = Imagecreate (130,15);  establishes a graphics imagecreate (130,15) bracket 130, 15 respectively representing width and height   4. $background _color = imagecolorallocate ($im, 255, 255, 255);  Set the background color imagecolorallocate assign a color to a picture ($im, 255, 255, 255 Im represents the 3 255 after the new graphic mentioned earlier, which represents the 10 character   5 of the color table FFFFFF. 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 '] You can use the $_server[' http_client_ip ' to use the following analogy to determine if this segment is compatible with multiple server settings   7. $col = imagecolorallocate ($im, 0, Wuyi, 102);  defines the text color   8. Imagestring ($im, 3, 5, 1, $ip, $col);  the acquired IP to the newly created canvas imagestring ($im, 3, 5, 1, $ip, $col); Represent imagestring (graphic representation, character size 1-5,x coordinates, y coordinates, output IP, color)   9. Imagegif ($im);  output GIF graphics   10. Imagedestroy ($im);  free memory   11. ?>  Program End  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.