Backend Development 2 min read

PHP decoct Function – Convert Decimal to Octal

This article explains the PHP decoct function, which returns the octal representation of a given decimal integer, details its parameter and return value, and provides example code demonstrating conversions such as 15 → 17 and 264 → 410.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP decoct Function – Convert Decimal to Octal

The decoct function in PHP converts a decimal integer to its octal string representation. It accepts a single integer argument $number and returns a string containing the octal value, supporting numbers up to 4,294,967,295 (resulting in "37777777777").

Parameter:

int $number – the decimal value to be converted.

Return value:

A string representing the octal form of the provided number.

Example usage:

<?php
echo decoct(15)."\n";
echo decoct(264);
?>

Running the above code outputs:

17
410
backendPHPconversionphp-functionsdecimal-to-octaldecoct
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.