PHP bin2hex() Function | Convert Binary to Hexadecimal
PHP bin2hex() Function
The bin2hex() function in PHP converts the specified string value of ASCII characters to hexadecimal value.
Syntax
bin2hex(str)
Parameter
str(Required): This parameter represents the string to be converted into hexadecimal.
Return
This function returns the hexadecimal representation for the specified string.
Example 1
Output
The ASCII character is: Welcome to my World! The hexadecimal value: 57656c636f6d6520746f206d7920576f726c6421
Example 2
Output
The ASCII character is: #Welcome@ *to@ @my@ &World$! The hexadecimal value: 2357656c636f6d6540202a746f402020406d7940202026576f726c642421
Example 3
Output
The Binary value: 111011 The hexadecimal value: 313131303131 Converted Binary to Hexadecimal: 3b
Example 4
Output
The Binary value: The hexadecimal value: