
如何在Windows、macOS和Linux上安装Node.js和npm
wp_convert_bytes_to_hr ( $bytes )
wp_convert_bytes_to_hr: 这是一个将字节值转换为人类可读格式的函数。它可以用来以一种更可读的格式显示文件大小。
将一个整数的字节值转换为一个速记的字节值。
function wp_convert_bytes_to_hr( $bytes ) { _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); $log = log( $bytes, KB_IN_BYTES ); $power = (int) $log; $size = KB_IN_BYTES ** ( $log - $power ); if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { $unit = $units[ $power ]; } else { $size = $bytes; $unit = $units[0]; } return $size . $unit; }