pm_size_b_printing

Accepts the number of bytes and returns the formatted string with the value in bytes for printing.

Syntax

pm_size_b_printing ($bytes, $addB, $precision)

Parameters

bytes

      An integer value that specifies the number of bytes.

addB

      A boolean value that is true if the 'bytes' word should be added to the resulting string, false otherwise. The default setting is false.

precision

      A string value that specifies precision of the value to show. It is set to -1 by default (only the integer part of the value should be shown).

Returns

A string value that holds the passed in number of bytes in a special format.

Code Example

$num_bytes = 1024;

 

$num_bytes_to_print = pm_size_b_printing($num_bytes, true, 2);

$num_bytes_to_print1 = pm_size_b_printing($num_bytes, true, 0);

$num_bytes_to_print2 = pm_size_b_printing($num_bytes,true);

$num_bytes_to_print3 = pm_size_b_printing($num_bytes);

 

echo $num_bytes_to_print;

echo $num_bytes_to_print1;

echo $num_bytes_to_print2;

echo $num_bytes_to_print3;

 

// the result will look as follows:

// 1024.00 bytes

// 1024. bytes

// 1024. bytes

// 1024.

 

Remarks

The above code snippet shows the results of three invocations of this function, each time with different parameters.

Include: pm.php.