PHP Function Reference

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.

DecimalOctalDecimalOctal
11810
22911
331620
445062
55100144
66500764
7710001750

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