代碼: 選擇全部
switch (PHP_OS) {
case ('Darwin'):
exec('ioreg -rd1 -w0 -c AppleAHCIDiskDriver | grep Serial', $res);
$sna = explode('=', $res[0]);
foreach ($sna as $key => $value) {
$value = str_replace('"', '', $value);
if (trim($value) != 'Serial Number') {
$sn[] = trim($value);
}
}
break;
case ('Linux'):
exec('lsblk --nodeps -no name,serial', $res);
foreach ($res as $key => $value) {
$sn[] = substr($value, 5);
}
break;
case ('WINNT');
exec('wmic path win32_physicalmedia get Tag,SerialNumber', $res);
foreach ($res as $key => $value) {
$data = explode("\\", $value);
if (count($data) > 1) {
if ($data['0'] != '') {
$sn[] = $data['0'];
}
}
}
break;
default:
}