PHP pow

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : pow() function

Description

The pow() function raises the first number to the power of the second number.

Version

(PHP 4 and above)

Syntax

pow(a,b)

Parameters

Name

Description

Required /
Optional

Type

a

The first number or base number to use.

Required

Float/integer

b

The second number or the exponent.

Required

Float/integer

Return value

The result of raising a to the power of b.

Value Type : Float/integer

Pictorial Presentation

php-math-abc()

Example :

  1. echo pow(7,3) . '
    ';  

  2. echo pow(2,3) . '
    ';  

  3. echo pow(-2,3) . '
    ';  

  4. echo pow(-2,-3) . '
    ';  

  5. echo pow(-2,-3.2) . '
    ';  

  6. ?>   

Output :

343
8
-8
-0.125
NAN