1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Pow () PHP Function

By

Definition: In mathematics, an exponent is used to take a number and multiply it by itself a certian a number of times. For example 4^5 (four to the power of five) would be 4*4*4*4*4, or 1024. We can do the same thing in PHP using the pow () function. It is written as pow(base, power) ; Our previous example of 4^5 would be written as pow (4, 5) ;
Examples:
 <?php 
 echo pow(5, 3) ;
 echo "<br>";
 echo pow(-3, 3) ;
 echo "<br>";
 echo pow(2, 4) ;
 ?> 
This would output:
 125
 -27
 16
 
Please note that while this will most likely work for you, older versions of PHP have trouble using negative bases, and need some manipulation to work. They will return false.
Related Video
Basic PHP Syntax
Using PHP With HTML
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Exponent (Power Of, Raised Power) Function

©2014 About.com. All rights reserved.