Home >>PHP Math Functions >PHP pow() Function
PHP pow() function is used to calculate a base raised to the power of exponent. It is a generic function which is used with a given number raised to any specific value. It takes two parameters which are the base and exponent of the function. It returns the given input number raised to the specific power as output. If both the arguments passed to it are non-negative integers then result can be represented as an integer, otherwise it is returned as a float.
Syntax:
pow($base, $exp);
Parameter | Description |
---|---|
base | This is a required parameter. This parameter defines the base to use. |
exp | This is a required parameter. This parameter defines the exponent. |
Here is an example of pow() function in PHP:
<html> <body> <?php echo pow(1,5)."<br>"; echo pow(2,10)."<br>"; echo pow(10,10)."<br>"; echo pow(5,15)."<br>"; ?> </body> </html>
Here is another example of pow() function in PHP:
<html> <body> <?php echo pow(-1,3)."<br>"; echo pow(-2,10)."<br>"; echo pow(-5,-5)."<br>"; echo pow(2.4,3)."<br>"; echo pow(5,3.2)."<br>"; echo pow(-5,2.5)."<br>"; ?> </body> </html>