• PHP Video Tutorials

PHP - gmp_pow() Functions



Definition and Usage

The gmp_pow() function returns the result for the given number raise to the power.

Description

The gmp_pow() function takes in the number and the exp.The result will be returned for raising number to the power exp.

Syntax

gmp_pow ( GMP $base , int $exp ) : GMP

Parameters

Sr.No Parameter & Description
1

base

The base number.It can a GMP resource number , a gmp object or a numeric string.

2

exp

The positive power to raise the base..

Return Values

PHP gmp_pow() function returns a GMP rnumber. Please note 0 base raised to the power of 0 will return the value as 1.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_pow −

<?php
   $num = gmp_pow('10', 2);	
   echo "The result is : ".$num;
?>

This will produce following result −

The result is : 100

Example 2

Working of 0^0 using gmp_pow() −

<?php
   $num = gmp_pow('0', 0);	
   echo "The result is : ".$num;
?>

This will produce following result −

The result is : 1

Example 3

Working of hexadecimal numbers using gmp_pow() −

<?php
   $num = gmp_pow('0xFE', 2);	
   echo "The result is : ".$num;
?>

This will produce following result −

The result is : 64516
php_function_reference.htm
Advertisements