Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the php binary conversion function

Shulou Source: shulou.com Published: 2022-06-01 20:30:52 10月06日 Update

This article mainly introduces the php binary conversion function how to use the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this php conversion function how to use the article will have a harvest, let's take a look at it.

Php binary conversion functions are: 1, bindec () function, can convert the binary to decimal; 2, decbin () function; 3, octdec () function; 4, decoc () function; 5, hexdec () function; 6, dechex () function; 7, base_convert () function.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php binary conversion function

1. Bindec () function-- binary number is converted to decimal

You can use the bindec (binary string) function, which converts binary numbers to decimal numbers.

Output result:

3115877

2. Decbin () function-decimal number to binary number

You can use the decbin (decimal value) function, which converts a decimal number to a binary number.

Output result:

11111000110011111

3. Octdec () function-- Octal to decimal

You can use the octdec (octal string) function, which converts octal numbers to decimal numbers.

Output result:

3010158770

4. Decoc () function-decimal number to octal number

You can use the decoct (decimal value) function, which converts decimal numbers to octal numbers.

Output result:

36123063106

5. Hexdec ()-- hexadecimal number to decimal number

You can use the hexdec (hexadecimal string) function, which converts hexadecimal numbers to decimal numbers.

Output result:

3010460713430527

6. Dechex ()-- Decimal number to hexadecimal number

You can use the dechex (decimal value) function, which converts decimal numbers to hexadecimal numbers.

Output result:

1ea63346

7. Base_convert () function-- arbitrary binary conversion

Base_convert (number or string to be converted, primitive, binary to be converted) function, which can convert between arbitrary radix

Example:

Convert binary numbers to decimal

Convert decimal to binary number

Output result:

Octal number to decimal number

Output result:

Decimal number to octal number

Output result:

Hexadecimal number to decimal number

Output result:

Decimal number to hexadecimal number

This is the end of the article on "how to use the php binary conversion function". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to use the php binary conversion function". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Functions decimal decimal results output binary octal hexadecimal characters strings knowledge content articles between value easy to operate tutorials articles easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information OPPO Reno Linux Apple