Class Number
number class for convert number, convert file size from bytes to other or from other to bytes.
Methods summary
public
|
#
convertBaht( number $num, boolean $display_net = true, string $language = 'Thai' )
A shorter way to convert Baht to different languages in one class. You no need to initialize new Number[Language]() class just new Number() .
You may need to require/include the Number[Language].php file if you don't use composer.
A shorter way to convert Baht to different languages in one class. You no need to initialize new Number[Language]() class just new Number() .
You may need to require/include the Number[Language].php file if you don't use composer.
Parameters
- $num
- number integer or decimal. negative or positive.
- $display_net
- display net (ถ้วน). true to display, false to not display. Usually this is only works with Thai language.
- $language
- the language you want to use. accepted Thai, Eng. this will be use in new Number[Language] object automatically.
|
public
|
#
convertNumber( number $num, string $language = 'Thai' )
A shorter way to convert number to different languages in one class. You no need to initialize new Number[Language]() class just new Number() .
You may need to require/include the Number[Language].php file if you don't use composer.
A shorter way to convert number to different languages in one class. You no need to initialize new Number[Language]() class just new Number() .
You may need to require/include the Number[Language].php file if you don't use composer.
Parameters
- $num
- number integer or decimal. negative or positive.
- $language
- the language you want to use. accepted Thai, Eng. this will be use in new Number[Language] object automatically.
|
public
mixed
|
#
fromBytes( integer $size, string $unit = 'AUTO', integer $decimal = 2 )
convert file size from bytes to the unit you specified or automatically detect.
convert file size from bytes to the unit you specified or automatically detect.
Parameters
- $size
- file size in bytes only.
- $unit
- unit you want to convert. accepted values are AUTO, B, KB, KiB, ... more please refer to byte_units property.
- $decimal
- number of decimal.
Returns
mixed return converted file size as string if success, return false if failed to convert.
|
public
mixed
|
#
toBytes( string $size )
convert file size to bytes.
convert file size to bytes.
Parameters
- $size
- enter file size string such as 105 or 105B for 105 Bytes, 1KB for 1 Kilobyte, 1KiB for 1 Kibibyte. file size unit can be *B or *iB for binary and decimal.
Returns
mixed return false if failed to convert. return number if it is able to convert.
|
Properties summary
protected
array
|
$byte_units
|
#
array(
'B' => 1,
'KiB' => 1024,
'KB' => 1000,
'MiB' => 1048576,
'MB' => 1000000,
'GiB' => 1073741824,
'GB' => 1000000000,
'TiB' => 1099511627776,
'TB' => 1000000000000,
'PiB' => 1125899906842624,
'PB' => 1000000000000000,
'EiB' => 1152921504606846976,
'EB' => 1000000000000000000,
'ZiB' => 1180591620717411303424,
'ZB' => 1000000000000000000000,
'YiB' => 1208925819614629174706176,
'YB' => 1000000000000000000000000,
)
|