This function takes a decimal value integer and returns a string of its octal representation. In base eight, the digits range from zero to seven. The decimal 8 would then be represented as the octal number 10.

If you pass it a float, it will be truncated (not rounded). Passing in a negative number may return unexpected results.

The function octdec() does the opposite as you can guess. Feed it the octal form and get the decimal.

$oct = decoct(4);   // 4
$oct = decoct(4.8); // 4
$oct = decoct(17);  // 21
 
$oct = decoct(-4); // 37777777774
 
// strings will be converted to integer
$oct = decoct('Q');  // 0
$oct = decoct('4Q'); // 4