Php: getting server ip address _ PHP Tutorial

Source: Internet
Author: User
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...

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.