Coding Villa

Check variable is Integer or not using is_Integer() function in PHP

Author : Nouman Zaidi

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

Description


In this simple article you will learn that how we can check variable is Integer or not using is_Integer() function in PHP


Advertisements


Integer Data Type:

 

An integer is whole number value. In simple words it is a number with no fractional component. In PHP integer is the same as in other programming language having number value range between:

-2,147,483,648 and +2,147,483,647.

 

 

In PHP you can also declare variable without mentioning their data type. As PHP is loosely bounded language and will try to determine type of variable based on the value hold by variable.

 

Declaration of variable without its type:

$variable =41;

 

$Value_Int=45; 

$Value_Int2=-78;



Here the variable hold the whole number value so it is of integer type.

 

 

Check variable using is_integer() function in PHP:

 

To check whether the variable is integer data type or not php supports built in functions name as is_integer() function. This function takes integer value as a parameter and returns a 1 if true and nothing if the variable is not integer type value.

 

Code:

<?php

$a = 0.89;

$b = -341;

$c = 0.006;

$d = 122;

echo( is_integer($a) );

echo "</br>";

echo( is_integer($b) );

echo "</br>";

echo( is_integer($c) );

echo "</br>";

echo( is_integer($d) );

?>

This is simple code to check variable is integer data type or not using is_integer() function.

 

This simple article tells that how we can check variable is integer data type or not using is_integer() function 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