Home > Article > Backend Development > PHP get current server details
I am currently using PHP to write an enterprise-level CMS. I need to use PHP in the background to obtain the detailed information of the current server and related system parameter information. I have sorted it out and posted it here for future use.
Get the system type and version number: php_uname() (Example: Windows NT COMPUTER 5.1 build 2600)
Only get the system type: php_uname('s') (or: PHP_OS, 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: apache2handler)
Get the pre-process user name: Get_Current_User()
Get 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"] (return Value is domain name or IP)
Get server IP: GetHostByName($_SERVER['SERVER_NAME'])
Server IP that accepts requests: $_SERVER["SERVER_ADDR"] (Sometimes it cannot be obtained, it is recommended to use: GetHostByName($_SERVER['SERVER_NAME']) )
Get the client IP: $_SERVER['REMOTE_ADDR']
Get the server interpretation engine: $_SERVER['SERVER_SOFTWARE']
Get the server CPU number: $_SERVER['PROCESSOR_IDENTIFIER']
Get server system directory : $_SERVER['SystemRoot']
Get the server domain name (host 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']
Get the name and version of the communication protocol when requesting the page: $_SERVER['SERVER_PROTOCOL'] For example, " HTTP/1.0".
The above introduces PHP to obtain the current server details, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.