Jump to content

[SOLVED] two functions not working at the same time


lewis987

Recommended Posts

basically to functions to get the free size left on the hard-drive and another to get the total space on it. code below.

 

$dir = $server1['data'];
$size = disk_total_space($dir);
function formatTotal($size){
    switch (true){
    case ($size > 1048576):
        $size /= 1048576;
        $suffix = 'MB';    
    break;
    case ($size > 1024):
        $size /= 1024;
        $suffix = 'KB';
        break;
    default:
        $suffix = 'B';
    }
    return round($size, 2).$suffix;
}

$goose = disk_free_space($dir);
function zz($goose){
    switch (true){
    case ($size > 1048576):
        $size /= 1048576;
        $suffix = 'MB';    
    break;
    case ($size > 1024):
        $size /= 1024;
        $suffix = 'KB';
        break;
    default:
        $suffix = 'B';
    }
    return round($size, 2).$suffix;
}

 

if i echo $goose it shows the space in bytes but i want it to show it in MB or KB depending on the size. Im on PHP 4.4.9 (i believe). Basically its when i cann formatTotal it shows the total space (that one works fine) but when i call "zz" it just shows me "0B" and when i show $goose i get the proper size in bytes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.