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