How to use bin2hex in PHP
In this article I am going to explain how the bin2hex() function can be used in PHP.
bin2hex() function in PHP
- The bin2hex() function is used to convert a string of binary characters to hexadecimal values.
- The pack() function can be converted string to back.
Syntax
Parameter
- string string is required parameter. determine the string to be converted.
Example
The following example show to how the bin2hex() function can be used in PHP.
<html>
<body>
<h3 style="color: blueviolet;">bin2hex() function example in PHP</h3>
<?php
$str = "C-sharpcorner!";
echo "Convert binary value : </br>";
echo bin2hex($str) . "<br />";
echo pack("H*",bin2hex($str)) . "<br />";
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here