w3resource

PHP: decoct() function

Description

The decoct() function is used to convert a decimal number to an octal number.

Version:

(PHP 4 and above)

Syntax:

decoct(num)

Parameter

Name Description Required /
Optional
Type
num The decimal value to convert  Required Integer

Return value:

Octal string representation of num.

Value Type:String.

Pictorial Presentation

php-math-decoct()

Example:

<?php
$val1= 120;
$val2=7;
$val3=9899;
$zoctal1=decoct($val1);
$zoctal2=decoct($val2);
$zoctal3=decoct($val3);
echo "Octal value of $val1 is $zoctal1<br />";
echo "Octal value of $val2 is $zoctal2<br />";
echo "Octal value of $val3 is $zoctal3<br />";
?>

Output :

Octal value of 120 is 170
Octal value of 7 is 7
Octal value of   9899 is 23253

View the example in the browser

See also

PHP Function Reference

Previous: dechex
Next: deg2rad



Follow us on Facebook and Twitter for latest update.