Php obtains the ip address of the server. A simple IP address can only be used to obtain the IP address on the server and cannot be used on the client. For more information, see. The code is as follows: Copy the code *** to get a simple IP address of the server to obtain the code. However, this can only be because the IP address obtained on the server cannot be used on the client. For more information, see.
The code is as follows: |
|
/** * Obtain the server ip address * @ Access public * @ Return string **/ Function real_server_ip (){ Static $ serverip = NULL; If ($ serverip! = NULL ){ Return $ serverip; } If (isset ($ _ SERVER )){ If (isset ($ _ SERVER ['server _ ADDR ']) { $ Serverip = $ _ SERVER ['server _ ADDR ']; } Else { $ Serverip = '0. 0.0.0 '; } } Else { $ Serverip = getenv ('server _ ADDR '); } Return $ serverip; } |
Bytes. The code is as follows/*** get the server...