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 convert binary to Decimal by php

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

Share

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

This article introduces the relevant knowledge of "how php converts binary to decimal". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Php converts binary to decimal: 1, use bindec () function, syntax "bindec ($binary_string)"; 2, use base_convert () function, syntax "base_convert ($binary_string,2,10)".

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

Php converts binary to decimal

1. Use the bindec () function

The bindec ($binary_string) function converts the binary number $binary_string to a decimal number.

Output result:

2. Use the base_convert () function

The base_convert () function converts numbers between arbitrary digits.

Base_convert ($binary_string,$frombase,$tobase)

$binary_string is required. Specifies the binary number to be converted.

$frombase is required. Specify the original base of the number. Between 2 and 36 (inclusive). Numbers higher than decimal are denoted by the letter amurz, for example, a for 10, b for 11, and z for 35.

$tobase is required. Specify the base to be converted. Between 2 and 36 (inclusive). Numbers higher than decimal are denoted by the letter amurz, for example, a for 10, b for 11, and z for 35.

Output result:

That's all for "how php converts binary to decimal". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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: 213

*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