format_units function

The format_units function formats an integer byte value in the most appropriate human readable form, for example, KB, MB, or GB. This function is part of the idsadmin class, which provides a library of basic functions for plug-ins for the HCL OpenAdmin Tool (OAT) for Informix®.

Syntax

format_units($value,$prec=2 )
Variable Purpose Restrictions
value The integer value in bytes. Must be an integer.
prec The precision of the formatted number. Optional. Must be an integer. The default is 2, which specifies 2 decimal places.

Return values

The return value is the formatted number with a suffix that indicates the units: B, KB, MB, GB, TB, PB, or EB.

Example

This example results in the $formatted_page_size variable holding the formatted value 2 K.

$page_size = 2048;
$formatted_page_size = $this->idsadmin->format_units($page_size);

Copyright© 2018 HCL Technologies Limited