The decoct()
function converts a decimal number into an octal number. It takes just
one parameter, which is the number to convert.
PHP decoct() Function has the following format.
string decoct ( int num )
Parameter | Is Required | Description |
---|---|---|
num | Required. | Decimal value to convert |
Item | Description |
---|---|
Return Value | A string that contains the octal number of the decimal value |
Return Type | String |
To convert octal to decimal, use the octdec() function.
Convert decimal to octal:
<?php
echo decoct("30") . "\n";
echo decoct("10") . "\n";
echo decoct("17") . "\n";
echo decoct("70") . "\n";
print decoct(19); // "23"
?>
The code above generates the following result.