# Hexdec()

Today, we will discuss the `hexdec()` function in PHP. This function is used to convert a hexadecimal number to its decimal equivalent.

## What is the hexdec() Function?

The `hexdec()` function in PHP is a built-in function that is used to convert a hexadecimal number to its decimal equivalent. A hexadecimal number is a number represented in base-16, while a decimal number is represented in base-10. The `hexdec()` function takes a hexadecimal number as input and returns its decimal equivalent as an integer.

## How to Use the hexdec() Function

Using the `hexdec()` function in PHP is very simple. Here is an example of how to use the function:

``````<?php
\$hex_number = "1a";

// Convert the hexadecimal number to its decimal equivalent using the hexdec() function
\$decimal_number = hexdec(\$hex_number);

// Output the decimal equivalent
echo \$decimal_number;
?>``````

In this example, we set a hexadecimal number as a string variable. We then call the `hexdec()` function with the hexadecimal number as a parameter to convert it to its decimal equivalent. Finally, we output the decimal equivalent to the screen.

## Conclusion

The `hexdec()` function in PHP is a useful tool for any PHP developer working with hexadecimal numbers. By using this function, you can convert a hexadecimal number to its decimal equivalent, which can be useful in a variety of applications. We hope that this guide has been helpful in understanding how to use the `hexdec()` function in your PHP code.