php如何取得系统环境变量,如分区信息,磁盘内存大小等 没有这么详细的信息吧。disk_free_space -- 返回目录中的可用空间disk_total_space -- 返回一个目录的磁盘总大小这样子简单的倒是有。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自己顶一下内存怎么求啊 或者CPU使用情况也可以阿。 你研究一下phpsysinfo的源代码吧,里面什么都有了,连硬件配置都能列出来。 http://prdownloads.sourceforge.net/phpsysinfo/phpsysinfo-2.5.2-rc1.tar.gz?download楼上说的不错,phpsysinfo不错,可以研究。 研究好了,使用COM作的。谢谢各位,做好后发出来 结帖! 问题解决,使用WMI,下面给出取物理内存的代码,还可以取得虚拟内存、CPU、磁盘等所有系统信息。$objLocator = new COM("WbemScripting.SWbemLocator");$wmi = $objLocator->ConnectServer();$buffer = _GetWMI($wmi, "Win32_LogicalMemoryConfiguration", array( "TotalPhysicalMemory" ) );$results['total'] = $buffer[0]["TotalPhysicalMemory"];$buffer = _GetWMI($wmi, "Win32_PerfRawData_PerfOS_Memory", array( "AvailableKBytes" ) );$results['free'] = $buffer[0]["AvailableKBytes"];$results['used'] = $results['total'] - $results['free'];$results['percent'] = ceil( ( $results['used'] * 100 ) / $results['total'] );function _GetWMI($wmi, $strClass, $strValue = array() ) { $objWEBM = $wmi->Get($strClass); if( PHP_VERSION < 5 ) { $objProp = $objWEBM->Properties_; $arrProp = $objProp->Next($objProp->Count); $objWEBMCol = $objWEBM->Instances_(); $arrWEBMCol = $objWEBMCol->Next($objWEBMCol->Count); } else { $arrProp = $objWEBM->Properties_; $arrWEBMCol = $objWEBM->Instances_(); } foreach($arrWEBMCol as $objItem) { //reset($arrProp); $arrInstance = array(); foreach($arrProp as $propItem) { eval("\$value = \$objItem->" .$propItem->Name .";"); if( empty( $strValue ) ) { $arrInstance[$propItem->Name] = trim($value); } else { if( in_array( $propItem->Name, $strValue ) ) { $arrInstance[$propItem->Name] = trim($value); } } } $arrData[] = $arrInstance; } return $arrData; } 当然这是在window系统上的做法,phpsysinfo还支持其他很多系统,具体方法在研究拉!结贴! 求一 SQL语句 Magic Quotes GPC怎么设置为ON 很奇怪的一个问题 关于mysql的text类型字段 求一正则,写了一天了,郁闷中 再次提问php 截取字符串的问题.(再加100分,如果解决两个贴子一起给分。) 哪大大帮我研究下这个字符串的截取 utf8 or utf-8 ? PHP时间格式转换方法 PHP发送电子邮件 php修改数据库记录,求大神 关于登陆“后”权限验证的问题! 请教phpwind的登陆页面怎么写??
内存怎么求啊 或者CPU使用情况也可以阿。
楼上说的不错,phpsysinfo不错,可以研究。
谢谢各位,做好后发出来 结帖!
$objLocator = new COM("WbemScripting.SWbemLocator");
$wmi = $objLocator->ConnectServer();
$buffer = _GetWMI($wmi, "Win32_LogicalMemoryConfiguration", array( "TotalPhysicalMemory" ) );
$results['total'] = $buffer[0]["TotalPhysicalMemory"];$buffer = _GetWMI($wmi, "Win32_PerfRawData_PerfOS_Memory", array( "AvailableKBytes" ) );
$results['free'] = $buffer[0]["AvailableKBytes"];
$results['used'] = $results['total'] - $results['free'];
$results['percent'] = ceil( ( $results['used'] * 100 ) / $results['total'] );function _GetWMI($wmi, $strClass, $strValue = array() ) {
$objWEBM = $wmi->Get($strClass); if( PHP_VERSION < 5 ) {
$objProp = $objWEBM->Properties_;
$arrProp = $objProp->Next($objProp->Count);
$objWEBMCol = $objWEBM->Instances_();
$arrWEBMCol = $objWEBMCol->Next($objWEBMCol->Count);
} else {
$arrProp = $objWEBM->Properties_;
$arrWEBMCol = $objWEBM->Instances_();
} foreach($arrWEBMCol as $objItem)
{
//reset($arrProp);
$arrInstance = array();
foreach($arrProp as $propItem)
{
eval("\$value = \$objItem->" .$propItem->Name .";");
if( empty( $strValue ) ) {
$arrInstance[$propItem->Name] = trim($value);
} else {
if( in_array( $propItem->Name, $strValue ) ) {
$arrInstance[$propItem->Name] = trim($value);
}
}
}
$arrData[] = $arrInstance;
}
return $arrData;
}