English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP bin2hex() Function Usage and Example

PHP String String Functions Manual

    bin2The hex() function is used to convert a binary string containing data into a hexadecimal value

Syntax

string bin2hex ( string $str )

Definition and Usage

 Converts the binary parameter str to a hexadecimal string. The conversion uses byte-wise, with the most significant byte first.

Return Value

It returns the escaped string

Parameter

Serial NumberParameter and Description
1

str

Binary String.

Online Example

Try the following example, convert "w3codebox" converted to hexadecimal value:

<?php
   //Convert "w3codebox" converted to hexadecimal value
   $binary = "w3codebox";
   $hex = dechex(bindec($binary));
   
   echo $hex;
?>
Test and See ‹/›

Output Result

0

PHP String String Functions Manual