BASE . LOG,
'file_id' => $LOG_FILE_ID,
// add file date
'print_file_date' => true,
// set debug and print flags
'debug_all' => $DEBUG_ALL,
'echo_all' => $ECHO_ALL ?? false,
'print_all' => $PRINT_ALL,
]);
$byte_class = 'CoreLibs\Convert\Byte';
$PAGE_NAME = 'TEST CLASS: BYTE CONVERT';
print "";
print "
" . $PAGE_NAME . "";
print "";
print '';
print '' . $PAGE_NAME . '
';
// class
$byte = 254779258;
$string = '242.98 MB';
// static
print "S::BYTE TO (calls as var): $byte: " . $byte_class::humanReadableByteFormat($byte) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_SI) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_NOSPACE) . "
";
print "S::BYTE FROM: $string: " . Byte::stringByteFormat($string) . "
";
//
$byte = 314572800;
$string = '300 MB';
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_SI) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST) . "
";
print "S::BYTE TO: $byte: "
. Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST | Byte::BYTE_FORMAT_NOSPACE) . "
";
print "S::BYTE TO: $byte: " . Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_NOSPACE) . "
";
print "S::BYTE FROM: $string: " . Byte::stringByteFormat($string) . "
";
// *** BYTES TEST ***
$bytes = [
-123123123,
999999, // KB-1
999999999, // MB-1
254779258, // MB-n
999999999999999, // TB-1
588795544887632, // TB-n
999999999999999999, // PB-1
9223372036854775807, // MAX INT
999999999999999999999, // EB-1
];
print "BYTE FORMAT TESTS
";
foreach ($bytes as $byte) {
print '';
//
print '
';
print "(" . number_format($byte) . "/" . $byte . ") bytes :";
$_bytes = Byte::humanReadableByteFormat($byte);
print '
' . $_bytes;
print '
';
print Byte::stringByteFormat($_bytes);
print "
";
//
print "
";
//
print '';
//
print '
';
print "bytes [si]:";
$_bytes = Byte::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_SI);
print '
' . $_bytes;
print '
';
print Byte::stringByteFormat($_bytes);
print "
";
//
print "
";
}
// error message
print $log->printErrorMsg();
print "";
// __END__