<?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);
| Parameter | DESCRIPTION |
|---|---|
| $number | Required : Decimal number as Input to convert to equivalent octal base number. |
$hex_value = 'A1';
$decimal_value = hexdec($hex_value);
echo decoct($decimal_value); // Output: 241
$large_number = 123456789;
echo decoct($large_number); // Output: 726746425
$binary_value = '1101';
$decimal_value = bindec($binary_value);
echo decoct($decimal_value); // Output: 15
$negative_value = -100;
echo decoct($negative_value); // Output: 37777777634 (negative numbers in octal)
$number = '123';
$decimal_value = (int)$number;
echo decoct($decimal_value); // Output: 173 (string treated as integer)
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.