Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


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

Syntax

decoct(number)

Parameters

number Required. Specify the decimal number to convert.

Return Value

Octal string representation of a decimal number.

Example:

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

<?php
$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

5