PHP Function Reference

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.

OctalDecimalOctalDecimal
11108
22119
332016
446250
55144100
66764500
771750100

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