• PHP Video Tutorials

PHP - gmp_​perfect_​power() Function



Definition and Usage

The gmp_​perfect_​power() function checks if the GMP number is a perfect power.

Description

The gmp_perfect_power() returns true if the GMP number is a perfect power and false if not.

Syntax

gmp_perfect_power ( mixed $a ) : bool

Parameters

Sr.No Parameter & Description
1

a

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

Return Values

PHP gmp_perfect_power() function returns a boolean value true if the GMP number is perfect power and false if not.

PHP Version

This function will work from PHP Version greater than 7.3.0.

Example 1

Working of gmp_perfect_power() −

<?php
   $bflag = gmp_perfect_power('144');
   if ($bflag) {
      echo "Perfect Power";
   } else {
      echo "Not a Perfect Power";
   }
?>

This will produce following result −

Perfect Power

Example 2

Working of gmp_perfect_square() −

<?php
   $bflag = gmp_perfect_power('1441');
   if ($bflag) {
      echo "Perfect Power";
   } else {
      echo "Not a Perfect Power";
   }
?>

This will produce following result −

Not a Perfect Power
php_function_reference.htm
Advertisements