The hex2bin method in PHP can be used to convert a hexadecimally encoded string to a binary string. However, this method doesn’t convert a hexadecimal number to a binary number.
hex2bin(string $string): string|false
hex2bin takes the hex string that will be converted to a binary string as a parameter.
The hex2bin method returns a string upon success; otherwise, it returns false.
In this example, we are going to decode the encoded string Hello, educative!.
<?phpecho hex2bin("48656c6c6f2c2065647563617469766521");