Home >>PHP Math Functions >PHP octdec() Function

PHP octdec() Function

PHP octdec() Function

PHP octdec() function is used to calculate the decimal equivalent value of a given input octal number. It converts the numbers that are too large to fit into the integer type. It accepts only a single parameter $number that is a string which represents the octal number whose decimal equivalent is to be found. It returns the decimal representation of the given octal number as output.

Syntax:

  octdec($number);

Parameter Values

Parameter Description
number This is a required parameter. This parameter defines the octal string to convert.

Here is an example of octdec() function in PHP:

<html>
<body>

<?php

echo octdec("6") . "<br>";
echo octdec("16") . "<br>";
echo octdec("26") . "<br>";
echo octdec("2346");

?>

</body>
</html>
Output:
6
14
22
1254

Here is another example of octdec() function in PHP:

<html>
<body>

<?php

echo decoct("8")."<br>";  
echo octdec("10")."<br>";  //octal value of 8 is 10

$a = decoct("500");
echo $a."<br>";
echo octdec($a)."<br>";

echo "The octal value of ".octdec("123")." is 123..";

?>

</body>
</html>
Output:
10
8
764
500
The octal value of 83 is 123..