PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - Math decoct() Function

The PHP Math decoct() function returns a string which is the octal representation of a decimal number.




number Required. Specify the decimal number to convert.

Return Value

Octal string representation of a decimal number.


In the example below, decoct() function returns the octal string representation of a given decimal number.

$x = 100; 
$y = 500;
$z = 1000;

echo "decoct($x) returns: ".decoct($x)."\n";
echo "decoct($y) returns: ".decoct($y)."\n";
echo "decoct($z) returns: ".decoct($z)."\n";

The output of the above code will be:

decoct(100) returns: 144
decoct(500) returns: 764
decoct(1000) returns: 1750

❮ PHP Math Functions