CopyPastehas never been so tasty!

Compare integer using comparison operator in PHP

by anonymous

  • 0
  • 0
  • 0


 Orignal Source:

Integer Data Type:


In PHP integer is single-value type. Integers are whole numbers. Its range varies according to your platform. But you can use any number from -2,147,483,648 to +2,147,483,647. Integer can be written in decimal, octal and hexadecimal.


We can represent Decimal without zero, octal with a leading 0 and a sequence of digits from 0 to 7,hexadecimal with 0-9 and alphabets A-F. 


For example:


1998 (Decimal)
0755  (Octal) 


Comparison operator:


By using Comparison operator we can compare two values in PHP.Comparison operator as its name shows allow to compare values.




$a == $b



Comparison operator in PHP:


To compare integers in PHP we use comparison operator. In the code below there in an example of comparing two integer values. If variable $a is equal to variable $b then print equal otherwise not equal.









echo "a = $a<br>";

echo "b = $b<br>";


   echo 'a "is equal to" b!';


echo 'a "is not equal to" b!';




This is simple code to compare integer values using comparison operator in PHP.


This simple article tells that how we can compare integer values using comparison operator in PHP.



Add A Comment: