Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert binary to hexadecimal by php

Shulou Source: shulou.com Published: 2022-06-02 01:44:04 10月02日 Update

This article mainly introduces the relevant knowledge of php how to convert binary to hexadecimal, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this php article on how to convert binary to hexadecimal. Let's take a look.

Php binary to hexadecimal methods: 1, to create a PHP sample file; 2, through the bin2hex () function to convert the string of ASCII characters to hexadecimal values.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

How does php convert binary to hexadecimal?

Binary to hexadecimal

Function: bin2hex (string $str)

@ param $str the string of ASCII characters to be converted.

@ return returns the hexadecimal value of the converted string.

Function description:

The bin2hex () function converts a string of ASCII characters to a hexadecimal value. Strings can be converted back by using the pack () function.

The bin2hex () function conversion uses bytes, and the high four-digit word takes precedence.

Example:

(1) bin2hex () converts' chengdu' to a hexadecimal value:

Tags: Hexadecimal character binary function string knowledge content program article statement output value byte simple operation file article way method easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Xiaomi Huawei Shulou Technology