PHP pow() Function
Syntax
pow(base, exponent);
Parameter | Description |
Base | Number can be integer or float |
Exponent | Number can be integer or float |
Definition
It returns the value of base raised to the power of exponent.
Usage
Pow() function is used to find multiplication of first argument itself second parameter times.
For example 52 =25. In case of pow function 5 is first argument (base) and 2 is second argument (exponent) of pow function.
Note: The pow function is capable of handled the negative power and exponent also.
Example of pow function
<?php echo "10 to power 3="; echo pow( 10, 3 ); ?>
- Example
- Run
More example of pow function
<?php echo "10 to power -3="; echo pow( 10, -3 ); echo "10 to power 0.5="; echo pow( 10, 0.5); ?>
- Example
- Run
pow function easily handle the float and negative number as shown above.
In first pow function, first argument (base) is 10 and second argument (exponent) is -3 so that result will be 0.001 not 1000.