PHP implementation code for graphical display IP address _php tutorial

Source: Internet
Author: User

  ("Content-type:image/gif"= Imagecreate (130,15= Imagecolorallocate (, 255, 255, 255(
            
              ([' http_client_ip ' 
                
                =[' http_client_ip ' 
                  
                     ( Span $_server< span>[' http_x_forwarded_for ' 
                     
                      =[' HTTP_X_ Forwarded_for ' 
                        
                         =[' REMOTE _addr ' 
                             
                               = imagecolorallocate ( , 0, Wuyi, 102
                                  
                                   , 3, 5, 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/714718.html www.bkjia.com true http://www.bkjia.com/PHPjc/714718.html techarticle ? ("Content-type:image/gif" = imagecreate (130,15 = Imagecolorallocate (, 255, 255, 255 ([' http_client_ip ' = [' HTTP_CLIE Nt_ip ' ([' http_x_forwarded_for ' = [' Http_x_forwarded_fo ...

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