PHP Get server IP and other detailed information

WBOY
Release: 2016-07-28 08:27:02
Original
2722 people have browsed it

getimagesize() function is used to obtain image size, type and other information. The

imagesx() function is used to get the width of the image. The

imagesy() function is used to get the height of the image.

Client IP related variables
1. $_SERVER['REMOTE_ADDR']; Client IP may be the user's IP or the proxy's IP.
2. $_SERVER['HTTP_CLIENT_IP']; The proxy IP may exist and can be forged.
3. $_SERVER['HTTP_X_FORWARDED_FOR']; Which IP the user is using as a proxy may exist and can be forged.
Server-side IP related variables
1. $SERVER_NAME needs to be obtained using the function gethostbyname(). This variable displays correctly on both the server and client sides.
2. $HTTP_SERVER_VARS["SERVER_ADDR"], tested on the server side: 127.0.0.1 (this is related to the setting value of BindAddress in httpd.conf). The test results on the client are correct.

3. $_SERVER['LOCAL_ADDR'], $HTTP_SERVER_VARS['LOCAL_ADDR'], during the test, no results were obtained (test environment PHP5).

Get the system type and version number: php_uname() (Or: PHP_OS, for example: Windows NT)
Only get the system version number : php_uname('r') (Example: 5.1) Get PHP running mode: php_sapi_name() (PHP run mode: apache2 handler)
Get the pre-process user name: Get_Current_User()
Get the PHP version: PHP_VERSION
Get the Zend version: Zend_Version ()
Get the PHP installation path: DEFAULT_INCLUDE_PATH
Get the absolute path of the current file: __FILE__

Get the Host value in the Http request: $_SERVER["HTTP_HOST"] (The return value is the domain name or IP)

Get server IP: GetHostByName($ _SERVER['SERVER_NAME'])
The server IP that accepts the request:                                                                                                                                                                                                                                                          Server server IP. VER ['REMOTE_ADDR']
Get the server interpretation engine:           $_SERVER['SERVER_SOFTWARE']
Get the server CPU number:             $_SERVER['PROCESSOR_IDENTIFIER']
Get the server system directory:             $_SERVER['SystemRoot']
 Get the server domain name: $_SERVER['SERVER_NAME'] (Recommended to use: $_SERVER["HTTP_HOST"])
Get the user domain name: $_SERVER['USERDOMAIN']
Get the server language: $_SERVER['HTTP_ACCEPT_LANGUAGE' ]
Get the server Web port: $ _SERVER['SERVER_PORT']

The above introduces how to obtain server IP and other detailed information in PHP, including aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!