a shot of dev knowledge

RELATED TAGS

What is pow() in PHP?

The pow() function calculates the value of the numberbase raised to the power of another numberexponent.

Figure 1 shows the mathematical representation of the pow() function.

Figure 1: Mathematical representation of pow() function

Syntax

number pow(baseNumber, exponent)

Parameters

The pow() function requires two parameters:

  • A base number.
  • An exponent number.

Return value

pow() returns the value of the base number raised to the exponent number.

Example

<?php
#positive: baseNumber     positive: exponent
echo("pow(2,3): ");
echo (pow(2,3));
echo("\n");
#positive: baseNumber     negative: exponent
echo("pow(0.25,-2): ");
echo (pow(0.25,-2));
echo("\n");
#negative: baseNumber     positive: exponent
echo("pow(-10,2): ");
echo (pow(-10,2));
echo("\n");
#negative: baseNumber     negative: exponent
echo("pow(-0.5,-1): ");
echo (pow(-0.5,-1));
?>

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring