Menu Close

bin2hex() function PHP

4.5
(13)

The bin2hex() function used to Convert binary data into hexadecimal representation

Returns an ASCII string containing the hexadecimal representation of string. The conversion is done byte-wise with the high-nibble first.

Syntax

bin2hex(string) 

Parameter Values

string : The string to be converted.

Technical Details

Return Value : Returns the hexadecimal value of the converted string.

PHP Version : 4+

Examples

<?php
$str = "Codeamend Team";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?> 

Output : 
436f6465616d656e64205465616d
Codeamend Team 

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 13

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Share

Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

You can also read...