Coding Villa

Compare integer using comparison operator in PHP

Author : nida khawar

Share with Friends
Views : 713
Ratings : 0
Bookmarks : 0
Farourities : 0

Description


In this simple article you will learn that how we compare integer using comparison operatorin PHP.


Advertisements


 

 

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)
0xFF(hexadecimal)


 

Comparison operator:

 

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

 

Syntax:

 

$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.

 

 

Code:

 

 

<?php

$a=100;

$b=true;

echo "a = $a<br>";

echo "b = $b<br>";

if($a==$b)

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

else

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.

 

 



Article Tags
Share with Friends

Comments




Leave a Reply

Name (required)  
Mail (will not be published) (required)   
 
Enter This Code
Captcha
 

Advertisements

Article Categories

.NET


Databases


Mobile Development


Operating Systems


Web Development


Coding Villa on Facebook