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