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
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
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/decoct.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics