php获取系统信息的方法_PHP教程

WBOY
发布: 2016-07-20 11:14:48
原创
989 人浏览过


用 getenv函数进行处理:

<?<span php
</span><span $root</span> = <span getenv</span>('DOCUMENT_ROOT'); <span //</span><span //服务器文档根目录</span>
<span $port</span> = <span getenv</span>('SERVER_PORT'); <span //</span><span //服务器端口</span>
<span $file</span> = <span getenv</span>('SCRIPT_NAME'); <span //</span><span //当前执行文件</span>
<span $ua</span> = <span getenv</span>('HTTP_USER_AGENT'); <span //</span><span //用户UA</span>
<span $method</span> = <span getenv</span>('REQUEST_METHOD'); <span //</span><span //请求方法</span>
<span $protocol</span> = <span getenv</span>('SERVER_PROTOCOL'); <span //</span><span //传输协议</span>
<span getmypid</span>(), <span //</span><span //返回当前PHP进程的进程ID号,该函数不需要输入参数。</span>
<span get_current_user</span>(), <span //</span><span //返回当前程序的所有者名称,该函数也不需要输入参数。</span>
?>
登录后复制

示例:

<?<span php
</span><span /*</span><span *
* php获取系统信息
* by www.jbxue.com
</span><span */</span><span 
获取系统类型及版本号: </span><span php_uname</span>() (例:Windows NT COMPUTER 5.1 build 2600<span )

只获取系统类型: </span><span php_uname</span>('s') (或:<span PHP_OS</span><span ,例:Windows NT)
只获取系统版本号: </span><span php_uname</span>('r') (例:5.1<span )
获取PHP运行方式: </span><span php_sapi_name</span><span () (PHP run mode:apache2handler)
获取前进程用户名: </span><span Get_Current_User</span><span ()
获取PHP版本: </span><span PHP_VERSION</span><span 
获取Zend版本: </span><span Zend_Version</span><span ()
获取PHP安装路径: </span><span DEFAULT_INCLUDE_PATH</span><span 
获取当前文件绝对路径: </span><span __FILE__</span><span 
获取Http请求中Host值: </span><span $_SERVER</span>["HTTP_HOST"<span ] (返回值为域名或IP)
获取服务器IP: </span><span GetHostByName</span>(<span $_SERVER</span>['SERVER_NAME'<span ])
接受请求的服务器IP: </span><span $_SERVER</span>["SERVER_ADDR"] (有时候获取不到,推荐用:<span GetHostByName</span>(<span $_SERVER</span>['SERVER_NAME'<span ]))
获取客户端IP: </span><span $_SERVER</span>['REMOTE_ADDR'<span ]
获取服务器解译引擎: </span><span $_SERVER</span>['SERVER_SOFTWARE'<span ]
获取服务器CPU数量: </span><span $_SERVER</span>['PROCESSOR_IDENTIFIER'<span ]
获取服务器系统目录: </span><span $_SERVER</span>['SystemRoot'<span ]
获取服务器域名: </span><span $_SERVER</span>['SERVER_NAME'] (建议使用:<span $_SERVER</span>["HTTP_HOST"<span ])
获取用户域名: </span><span $_SERVER</span>['USERDOMAIN'<span ]
获取服务器语言: </span><span $_SERVER</span>['HTTP_ACCEPT_LANGUAGE'<span ]
获取服务器Web端口: </span><span $_SERVER</span>['SERVER_PORT'<span ]
</span>?>
登录后复制

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440244.htmlTechArticle用 getenv函数进行处理: ? = ('DOCUMENT_ROOT'); = ('SERVER_PORT'); = ('SCRIPT_NAME'); = ('HTTP_USER_AGENT'); = ('REQUEST_METHOD'); = ('SERVER_PROTOCOL'); (), (), ? 示例:...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板