- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
gmp_cmp() function in PHP
The gmp_cmp() function compares two GMP numbers.
Syntax
gmp_cmp(n1, n2)
Parameters
n1 − The first GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.
n2 − The second GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.
Return
The gmp_cmp() function returns:
- 1 if first number is greater,
- -1 if second number is greater,
- 0 if both the numbers are equal
Example
The following is an example −
<?php $n1 = "32"; $n2 = "32"; $cmpres = gmp_cmp($n1, $n2); echo $cmpres; ?>
Output
The following is the output −
0
Example
Let us see another example −
<?php $n1 = "25"; $n2 = "30"; $cmpres = gmp_cmp($n1, $n2); echo $cmpres; ?>
Output
The following is the output −
-1
Advertisements