Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
Help keep Vanilla free:
function FormatFileSize($FileSize) {
if ($FileSize > 1048576) {
return intval((($FileSize / 1048576) * 100) + 0.5) / 100 . "mb";
} elseif ($FileSize > 1024) {
return ceil($FileSize / 1024)."kb";
} else {
return $FileSize."b";
}
}
return intval((($FileSize / 1048576) * 100) + 0.5) / 100."mb";return (intval((($FileSize / 1048576) * 100) + 0.5) / 100)."mb";return intval(((($FileSize / 1048576) * 100) + 0.5) / 100)."mb";
function testFormatFileSize() {
$FileSize = 1;
$TestSize = $FileSize*1024*1024;
$Result = FormatFileSize($TestSize);
$this->assertIdentical("1024kb", $Result);
$TestSize = $FileSize*1024;
$Result =FormatFileSize($TestSize);
$this->assertIdentical( "1024b", $Result);
$FileSizes = array(1.005, 2, 500);
foreach ($FileSizes as $FileSize) {
$TestSize = $FileSize*1024*1024;
$Result = FormatFileSize($TestSize);
$this->assertIdentical(round($FileSize, 2)."mb", $Result);
$TestSize = $FileSize*1024;
$Result =FormatFileSize($TestSize);
$this->assertIdentical( ceil($FileSize)."kb", $Result);
$TestSize = intval($FileSize);
$Result = FormatFileSize($TestSize);
$this->assertIdentical(intval($FileSize)."b", $Result);
}
}
print "php thinks that 100.\"mb\" is " . 100."mb";>> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in numtest.php on line 2print "php thinks that 100 .\"mb\" is " . 100 ."mb";>> php thinks that 100 ."mb" is 100mbreturn intval((($FileSize / 1048576) * 100) + 0.5) / 100 . "mb";return intval((($FileSize / 1048576) * 100) + 0.5) / 100."mb";1 to 4 of 4