Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the php binary conversion function

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report