PHP decoct() Function
In this chapter you will learn:
- Definition for PHP decoct() Function
- Syntax for PHP decoct() Function
- Parameter for PHP decoct() Function
- Return for PHP decoct() Function
- Note for PHP decoct() Function
- Example - converts a decimal number into an octal number
Definition
The decoct()
function converts a decimal number into an octal number. It takes just
one parameter, which is the number to convert.
Syntax
PHP decoct() Function has the following format.
string decoct ( int num )
Parameter
Parameter | Is Required | Description |
---|---|---|
num | Required. | Decimal value to convert |
Return
Item | Description |
---|---|
Return Value | A string that contains the octal number of the decimal value |
Return Type | String |
Note
To convert octal to decimal, use the octdec() function.
Example
Convert decimal to octal:
<?php/*from ja va2 s . c o m*/
echo decoct("30") . "\n";
echo decoct("10") . "\n";
echo decoct("17") . "\n";
echo decoct("70") . "\n";
print decoct(19); // "23"
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP deg2rad() Function
- Syntax for PHP deg2rad() Function
- Parameter for PHP deg2rad() Function
- Return for PHP deg2rad() Function
- Note for PHP deg2rad() Function
- Example - converts degrees to radians
Home » PHP Tutorial » PHP Math Functions