Example 1 — Convert Octal to Decimal
Pass an octal string to octdec() and get a decimal number back.
<?php
echo octdec("17"), PHP_EOL;
echo octdec("777"), PHP_EOL;
echo octdec("10"), PHP_EOL; How It Works
- octdec("17") calculates 1 x 8 + 7, which is 15.
- octdec("777") calculates 7 x 64 + 7 x 8 + 7, which is 511.
- octdec("10") calculates 1 x 8 + 0, which is 8.
- Each result is a normal decimal integer.

