PHP dechex() Function
In this chapter you will learn:
- Definition for PHP dechex() Function
- Syntax for PHP dechex() Function
- Parameter for PHP dechex() Function
- Return for PHP dechex() Function
- Note for PHP dechex() Function
- Example - converts a decimal number into a binary number
Definition
The dechex() function converts a decimal number into a binary number.
Syntax
PHP dechex() Function has the following format.
string dechex ( int num )
Parameter
Parameter | Is Required | Description |
---|---|---|
number | Required. | Decimal value to convert |
Return
Item | Description |
---|---|
Return Value | A string that contains the hexadecimal number of the decimal value |
Return Type | String |
Note
To convert hexadecimal to decimal, use the hexdec() function.
Example
Convert decimal to hexadecimal:
<?php// j a va2s.com
print dechex(232); // "e8"
print "\n";
echo dechex("30") . "\n";
echo dechex("10") . "\n";
echo dechex("1587") . "\n";
echo dechex("70");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP decoct() Function
- Syntax for PHP decoct() Function
- Parameter for PHP decoct() Function
- Return for PHP decoct() Function
- Note for PHP decoct() Function
- Example - converts a decimal number into an octal number
Home » PHP Tutorial » PHP Math Functions