get system total disk space in php

To get the total disk space of the system in PHP, the disk_total_space() function can be used. This function returns the total size of a given directory in bytes. If no directory is specified, it will return the total size of the partition the PHP script is running on. Here is an example code:

main.php
<?php
$total_space = disk_total_space("/");
echo "Total disk space: " . $total_space . " bytes";
?>
100 chars
5 lines

In this example, disk_total_space() function is called with the root directory path “/”. The function returns total disk space in bytes and prints it using echo. This code will output the total disk space in bytes of the system where it is running.

related categories

gistlibby LogSnag