Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert hexadecimal to decimal in php

Shulou Source: shulou.com Published: 2022-06-02 04:34:36 09月10日 Update

This article is about how hexadecimal and decimal are converted to each other in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Conversion methods: 1, use the "hexdec (hexadecimal string)" statement, you can convert hexadecimal to decimal numbers; 2, use the "dechex (decimal value)" statement, you can convert decimal to hexadecimal values; 3, use the "base_convert (" binary value ", primitive, target)" statement.

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

Conversion between hexadecimal and decimal

1, hexadecimal number to decimal number

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

Output result:

You can also use the base_convert () function by setting "bindec (hexadecimal string, 16,10)".

Output result:

3010460713430527

2, decimal number to hexadecimal value

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

Output result:

You can also use the base_convert () function, just set "bindec (decimal value, 10,16)".

Output result:

1ea63346

Thank you for reading! This is the end of the article on "how to convert hexadecimal to decimal in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Binary hexadecimal decimal function result output character string statement content just more article can be good practical tutorial article method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Shulou Information NVidia Xiaomi