PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - Math pow() Function



The PHP Math pow() function returns the base raise to the power of exponent. If both arguments of the function are non-negative integers the return type will be integer, else the return type will be float.

Syntax

pow(base, exponent)

Parameters

base Required. Specify the base.
exponent Required. Specify the exponent.

Return Value

Returns the base raise to the power of exponent.

Example:

In the example below, pow() function is used to calculate the base raised to the power of exponent.

<?php
$x = 2; $y = 3;
$p = 2.3; $q = 4;

echo "$x raised to the power of $y equals: ".pow($x, $y)."\n";
echo "$p raised to the power of $q equals: ".pow($p, $q)."\n";
?>

The output of the above code will be:

2 raised to the power of 3 equals: 8
2.3 raised to the power of 4 equals: 27.9841

❮ PHP Math Functions

5