- ?? decbin() ?????????????????:
$decimal = 10;
$binary = decbin($decimal);
echo $binary; // ?? 1010
- ??? decbin() ???????????,???? str_pad() ???????????:
$decimal = 10;
$binary = decbin($decimal);
$padded_binary = str_pad($binary, 8, '0', STR_PAD_LEFT);
echo $padded_binary; // ?? 00001010
- ???? sprintf() ???????????????:
$decimal = 10;
$binary = decbin($decimal);
$formatted_binary = sprintf('d', $binary);
echo $formatted_binary; // ?? 00001010
- ??? decbin() ?????????????,?????????:
function decimalToBinary($decimal) {
return decbin($decimal);
}
$binary = decimalToBinary(10);
echo $binary; // ?? 1010