Home  >  Article  >  Backend Development  >  How to parse system information in php_PHP tutorial

How to parse system information in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:03:16886browse

$root = getenv('DOCUMENT_ROOT'); ////Server document root directory
$port = getenv('SERVER_PORT'); ////Server port
$file = getenv('SCRIPT_NAME'); ////Current execution file
$ua = getenv('HTTP_USER_AGENT'); ////User UA
$method = getenv('REQUEST_METHOD'); ////Request method
$protocol = getenv('SERVER_PROTOCOL'); ////Transport protocol
getmypid(), ////Returns the process ID number of the current PHP process. This function does not require input parameters.
get_current_user(), ////Returns the owner name of the current program, and this function does not require input parameters.

Copy code The code is as follows:

Get the system type and version number: php_uname() (Example: Windows NT COMPUTER 5.1 build 2600)
Get only the system type: php_uname('s') (or: PHP_OS, for example: Windows NT)
Get only 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 the PHP version: PHP_VERSION
Get the Zend version: Zend_Ver sion()
Get 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 the server IP: GetHo stByName($_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 the server system directory:   $_SERVER[' SystemRoot']
Get the server domain name: $_SERVER['SERVER_NAME'] (Recommended: $_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']

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327854.htmlTechArticle$root = getenv('DOCUMENT_ROOT'); ////Server document root directory $port = getenv(' SERVER_PORT'); ////Server port $file = getenv('SCRIPT_NAME'); ////Current execution file $ua = getenv('...
Statement:
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