VOOZH about

URL: https://www.geeksforgeeks.org/php/php-gmp_perfect_square-function/

⇱ PHP | gmp_perfect_square() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP | gmp_perfect_square() Function

Last Updated : 11 Jul, 2025
The gmp_perfect_square() is an inbuilt function in PHP which checks if the given GMP number(GNU Multiple Precision: For large numbers) is a perfect square or not. Syntax:
gmp_perfect_square($num)
Parameters: The function accepts one GMP number $num. This parameter can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass a numeric string provided that it is possible to convert that string to a number. Return Value: The function returns true if the given number $num is a perfect square, otherwise it returns false. Examples:
Input : $num=25 
Output : true

Input : $num=10
Output : false
Below programs illustrate the use of gmp_perfect_square() function: Program 1: The program below demonstrates the working of gmp_perfect_square() function when GMP number is passed as an argument. Output:
bool(true) 
bool(true)
bool(false)
Program 2: The program below demonstrates the working of gmp_perfect_square() when numeric string is passed as an argument. Output:
bool(true) 
bool(true)
bool(false)
Reference: https://www.php.net/manual/en/function.gmp-perfect-square.php
Comment