Home  >  Article  >  Backend Development  >  The difference between is_int and is_numeric

The difference between is_int and is_numeric

WBOY
WBOYOriginal
2016-08-08 09:30:083181browse

is_int: It is a strong type judgment. When the parameter is a number of type int, return 1, otherwise return 0

is_numeric: It is a number/digit string (if it is a pure numeric string, if there are characters, it returns false ), return 1

example:

is_numeric(1234);//true

is_numeric('1234');//true

is_numeric ('1234e4');//false

is_numeric('1234 ');//false

So under normal circumstances, if the data passed from the front end is not forced to convert/int processing, it is best to use is_numeric(), which can ensure that the parameter judgment can pass

The above has introduced the difference between is_int and is_numeric, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn