The decoct
method converts a decimal number to an octal string.
Octal is the base-8 number system and uses digits 0 to 7.
decoct(int $num): string
The argument is the decimal number that will be converted to an octal string.
The maximum value that can be converted is based on the platform of the computer.
In 32-bit platforms, the largest decimal value that can be converted is 4294967295, resulting in 37777777777.
In 64-bit platforms, the largest decimal value that can be converted is 9223372036854775807, resulting in 777777777777777777777.
decoct
returns the octal value of the argument as a string.
<?php$num = 8;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 9;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 10;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 11;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 12;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 13;echo "octal value of ". $num. " is: ". decoct($num)."\n";$num = 100;echo "octal value of ". $num. " is: ". decoct($num)."\n";?>
In the code above, we use the decoct
method to convert the decimal numbers 8
, 9
, 10
, 11
, 12
, 13
, and 100
into octal representation.