Reports total filesystem capacity in bytes.
What Is disk_total_space() in PHP?
Reports total filesystem capacity in bytes.
Its syntax is:
disk_total_space(string $directory): float|false
Parameters:
$directory— Accepted as string; required argument.
Return type: float|false. Filesystem totals are not the same as user quotas or available free space.
Availability: Depends on filesystem and operating system.
Example 1: Basic Usage
<?php
var_dump(disk_total_space(sys_get_temp_dir()) !== false);
Output:
bool(true)
Filesystem totals are not the same as user quotas or available free space.
Example 2: A Different Input
<?php
echo disk_total_space(".") !== false ? "Available" : "Unavailable";
Output:
Available
Filesystem totals are not the same as user quotas or available free space.
Practical Example: Applying It in a Program
<?php
$folderPath = sys_get_temp_dir(); $totalBytes = disk_total_space($folderPath); if ($totalBytes !== false) { echo round($totalBytes / 1073741824, 2) . " GiB total"; }
Output:
31.45 GiB total
Filesystem totals are not the same as user quotas or available free space.
Important Behavior and Edge Cases
- Key behavior: Filesystem totals are not the same as user quotas or available free space.
- Environment: Depends on filesystem and operating system.
Comparison With Related Functions
| Function | Purpose |
|---|---|
disk_total_space() | Reports total filesystem capacity in bytes. |
disk_free_space() | disk_free_space() reports available capacity; disk_total_space() reports total capacity. |
Common Beginner Mistakes
| Mistake | Correct Approach |
|---|---|
| Ignoring this behavior: Filesystem totals are not the same as user quotas or available free space | Filesystem totals are not the same as user quotas or available free space. |
Key Takeaways
- Reports total filesystem capacity in bytes.
- Filesystem totals are not the same as user quotas or available free space.
- Depends on filesystem and operating system.
Summary: Filesystem totals are not the same as user quotas or available free space.