w3resource

PHP: bin2hex() function

PHP: Convert binary data into hexadecimal representation

The bin2hex() function converts a string of binary characters to hexadecimal values.

Version:

(PHP 4 and above)

Syntax:

bin2hex(string_name)

Parameter:

Name Description Required /
Optional
Type
string_name The string to be converted. Required String

Return values:

The hexadecimal representation of the given string.

Value Type: String.

Pictorial Presentation

php-string-bin2hex()

Example:

<?php
 $string_name='w3resource.com';
 echo bin2hex($string_name);
?>

Output:

77337265736f757263652e636f6d 

View the example in the browser

See also

PHP Function Reference

Previous: addcslashes
Next: chop



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/function-reference/bin2hex.php