PHP decoct() Function
The PHP decoct() function returns a string which is the octal representation of a decimal number.
The table below shows decimal numbers converted into octal numbers.
Decimal | Octal | Decimal | Octal |
---|---|---|---|
1 | 1 | 8 | 10 |
2 | 2 | 9 | 11 |
3 | 3 | 16 | 20 |
4 | 4 | 50 | 62 |
5 | 5 | 100 | 144 |
6 | 6 | 500 | 764 |
7 | 7 | 1000 | 1750 |
Syntax
decoct(number)
Parameters
number |
Required. Specify the decimal number to convert. |
Return Value
Octal string representation of a decimal number.
Example:
In the example below, decoct() function returns the octal string representation of a given decimal number.
<?php echo "decoct(0) = ".decoct(0)."\n"; echo "decoct(1) = ".decoct(1)."\n"; echo "decoct(8) = ".decoct(8)."\n"; echo "decoct(50) = ".decoct(50)."\n"; echo "decoct(64) = ".decoct(64)."\n"; echo "decoct(500) = ".decoct(500)."\n"; echo "decoct('1000') = ".decoct('1000')."\n"; echo "decoct('5000') = ".decoct('5000')."\n"; ?>
The output of the above code will be:
decoct(0) = 0 decoct(1) = 1 decoct(8) = 10 decoct(50) = 62 decoct(64) = 100 decoct(500) = 764 decoct('1000') = 1750 decoct('5000') = 11610
❮ PHP Math Reference