戻る

ディスクの総容量を調べる(参考)

disk_total_space()関数

ハードディスク上の総容量(使用済み容量+空き容量)を調べるにはdisk_total_space()関数を使います。この関数では、引数としてディレクトリ名を指定しますが、ディレクトリの容量ではなく、ディスクパーティション全体の総容量が返されます。返り値の単位は「バイト」です。

「disk_total_space("e:")のように特定のドライブ名を指定して、そのドライブの総容量を調べることもできます。

PHP

<?php
header("Content-type: text/html; charset=utf-8");

//ディスク総容量を取得
$totalbyte = disk_total_space(".");

echo number_format($totalbyte) ."バイトあります。<br>";

echo number_format($totalbyte / 1024) . "キロバイトあります。<br>";

echo number_format($totalbyte / pow(1024, 3)) . "ギガバイトあります。<br>";

//Dドライブの総容量を取得
echo number_format(disk_total_space("d:"));
?>

inserted by FC2 system