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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP hex2Usage and Examples of bin() Function

PHP String String Functions Manual

hex2The bin() function is used to convert the string of hexadecimal values to ASCII characters.

Syntax

string hex2bin( string $data )

Definition and Usage

Used to convert hexadecimal strings to ASCII characters

Return Value

Returns the converted ASCII characters, if the conversion fails it returns FALSE, and the original hexadecimal value string will not change.

Note: If the input hexadecimal string is of odd length or an invalid hexadecimal string, an E_WARNING level error will be thrown.

Parameter

Serial NumberParameters and Description
1

data

It contains information about the hexadecimal representation of data

Online Example

Try the following example to convert hexadecimal values to ASCII characters:

<?php
   //Convert Hexadecimal Values to ASCII Characters
   $hex = hex2bin("43480170);
   var_dump($hex);
?>
Test and See‹/›

Output Result-

string(4)  "CHp"

PHP String String Functions Manual