decoct():octal equivalent of decimal number

<?Php
echo decoct(5); // Output 5 
echo "<br>";
echo decoct(55); // Output 67 
echo "<br>";
echo decoct(500); // Output is 764
echo "<br>";
echo decoct(658); // Output is 1222
echo "<br>";
echo decoct(3000); // Output is 5670
?>
Syntax
string decoct(int $number);
ParameterDESCRIPTION
$numberRequired : Decimal number as Input to convert to equivalent octal base number.
The output is string converted to octal base system.

Example: Convert Hexadecimal to Octal

$hex_value = 'A1';
$decimal_value = hexdec($hex_value);
echo decoct($decimal_value);  // Output: 241

Example: Handling Large Numbers

$large_number = 123456789;
echo decoct($large_number);  // Output: 726746425

Example: Convert Binary to Octal

$binary_value = '1101'; 
$decimal_value = bindec($binary_value);
echo decoct($decimal_value);  // Output: 15

Example: Octal Conversion for Negative Numbers

$negative_value = -100;
echo decoct($negative_value);  // Output: 37777777634 (negative numbers in octal)

Example: Working with Octal and Strings

$number = '123';
$decimal_value = (int)$number;
echo decoct($decimal_value);  // Output: 173 (string treated as integer)

Math Functions base_convert(): Convert number From any base to other decbin() Binary equivalent of decimal number dechex(): Convert decimal number to hexadecimal system
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer