Source Code:
(back to article)
<?php $invalid_hex_string = "48656c6c6f20576f726c4"; $binary_string = hex2bin($invalid_hex_string); if ($binary_string === false) { $hex_string = bin2hex($invalid_hex_string); if ($hex_string === $invalid_hex_string) { echo "Invalid input: $invalid_hex_string"; } else { echo "Invalid input, could not be converted to binary: $invalid_hex_string"; } } else { echo $binary_string; } ?>
Result:
Report an issue