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 perform binary conversion in php

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "how to convert to binary in php", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to convert to binary in php" article.

Conversion methods: 1, using bindec (), you can convert binary to decimal; 2, using decbin (), you can convert decimal to binary; 3, using octdec (), you can convert octal to decimal; 4, using decoct (), you can convert decimal to octal; 5, using hexdec (), you can convert hexadecimal to decimal.

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

Php performs binary conversion

1. Bindec-- binary number to decimal number

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

Output result:

3115877

2. Decbin-- 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-- octal number to decimal number

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

Output result:

3010158770

4. Decoct-- 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-- arbitrary binary conversion

Using the base_convert (number or string to be converted, primitive, binary to be converted) function, it can convert between arbitrary radix

Just set "bindec (binary string, 2,10)" to convert a binary number to a decimal number.

Output result:

Decimal numbers can be converted to binary numbers by setting "bindec (decimal value, 10,2)"

Output result:

You can convert octal numbers to decimal numbers by setting "bindec (octal string, 8,10)"

Output result:

Decimal numbers can be converted to octal numbers by setting "bindec (decimal value, 10,8)"

Output result:

Set "bindec (hexadecimal string, 16,10)" to convert hexadecimal numbers to decimal numbers

Output result:

The decimal number can be converted to hexadecimal number by setting "bindec (decimal value, 10,16)"

Output result:

The above is about the content of this article on "how to convert binary in php". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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