if(strtoupper(substr(PHP_OS,0,3))==='WIN'){ //windows服务器
$free_space = number_format((disk_free_space("C:")/disk_total_space("C:")), 2);
}else{
$sh = shell_exec('df -lh | grep -E "^(/)"');
$sh = preg_replace("/\s{2,}/", ' ', $sh);
$hd = explode(" ", $sh);
// $hd_avial = trim($hd[3],'G');//可用空间G
// $hd_usage = trim($hd[4],'%');//已使用百分比
$hd_usage = number_format(trim($hd[4],'%')/100,2); //已使用 ex:0.51
$free_space = 1 - $hd_usage; //剩余空间
}
// $free_space*100.'%';//保留两位小数的百分比形式
shell_exec('df -lh | grep -E "^(/)"');