In this article, We’ll see what is the difference between is_int()
, is_integer()
and is_numeric()
in php?
Above functions looks like similar, but there is a difference.
is_int()
: It is used to check the type of a variable is integer.
is_integer()
: alias of is_int()
. It is also used to test whether the type of the specified variable is an integer or not.
is_numeric()
: It is used to check the variable is a number or a numeric string.
Let’s see the example:
$variable = "12345"; echo is_int($variable); // return false echo is_integer($variable); // return false echo is_numeric($variable); // return true
$variable
is a string of numbers, not an integer value.
is_int()
return false because it’s not an integer value, it’s a string.
is_numeric()
return true because it’s a numeric string.
$variable2 = 123; echo is_int($variable2); // return true echo is_integer($variable2); // return true echo is_numeric($variable2); // return true
$variable2
is a integer value, not a string of numbers.
is_int($variable2)
return true because it’s an integer value, not a string.
is_numeric($variable2)
return true because it’s a number.
That’s it!. Please share your thoughts or suggestions in the comments below.
You ought to take part in a contest for one of the best sites on the net.
I most certainly will highly recommend this blog!
Hello! This is my first visit to your blog! We are a group of volunteers and starting a new
project in a community in the same niche. Your blog provided us valuable information to work on. You have done a wonderful job!
It’s awesome designed for me to have a web page, which is good for my knowledge.
thanks admin
Spot on with this write-up, I absolutely feel this web site needs a lot more attention. I’ll probably be returning to read through more, thanks for the information!
Appreciating the hard work you put into your blog and detailed information you provide.
It’s good to come across a blog every once in a while that isn’t the same out of date rehashed
material. Fantastic read! I’ve saved your site and I’m including your RSS feeds to my Google account.
Hi, I do believe this is a great site. I stumbledupon it 😉 I will
revisit yet again since i have bookmarked it. Money and freedom is the best way to change,
may you be rich and continue to help others.