PHP - gmp_perfect_square() Function
Definition and Usage
The gmp_perfect_square() function checks if the GMP number is a perfect square.
Description
The gmp_perfect_square() returns true if the GMP number is a perfect square and false if not.
Syntax
gmp_perfect_square ( GMP $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_square() function returns a boolean value true if the GMP number is perfect square and false if not.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_perfect_square() −
<?php
$bflag = gmp_perfect_square('2685');
if ($bflag) {
echo "Perfect Square";
} else {
echo "Not a Perfect Square";
}
?>
This will produce following result −
Not a Perfect Square
Example 2
Working of gmp_perfect_square() −
<?php
$bflag = gmp_perfect_square('144');
if ($bflag) {
echo "Perfect Square";
} else {
echo "Not a Perfect Square";
}
?>
This will produce following result −
Perfect Square
php_function_reference.htm
Advertisements