is_int
Description
The is_int of Variable Handling for PHP find whether the type of a variable is integer.
Syntax
is_int(mixed $value): bool
Parameters
value
The variable being evaluated.
Return
Returns true if value is an int, false otherwise.
Examples
1
<? $value = 0; $return = is_int($value); var_dump($value, $return); ?>
int(0) bool(true)
2
<? $values = array(null, false, true, PHP_INT_MIN, PHP_INT_MAX, 0, 1, 23, -0, +0, -1, +1, -23, +23, 00, 01, 023, 0x0, 0x1, 0x23, 0.0, 1.1, 23.45, 0e10, 1e10, 23e10, "", "0", "1", "23", "-0", "+0", "-1", "+1", "-23", "+23", "00", "01", "023", "0x0", "0x1", "0x23", "0.0", "1.1", "23.45", "0e10", "1e10", "23e10", "0abc", "1abc", "23abc", "-0abc", "+0abc", "-1abc", "+1abc", "-23abc", "+23abc", "00abc", "01abc", "023abc", "0x0abc", "0x1abc", "0x23abc", "0.0abc", "1.1abc", "23.45abc", "0e10abc", "1e10abc", "23e10abc", "abc", "abc0", "abc1", "abc23", "abc-0", "abc+0", "abc-1", "abc+1", "abc-23", "abc+23", "abc00", "abc01", "abc023", "abc0x0", "abc0x1", "abc0x23", "abc0.0", "abc1.1", "abc23.45", "abc0e10", "abc1e10", "abc23e10", array(), array(0, 1)); foreach($values as $value) { $return = is_int($value); var_dump($value, $return); echo PHP_EOL; } ?>
NULL bool(false) bool(false) bool(false) bool(true) bool(false) int(-9223372036854775808) bool(true) int(9223372036854775807) bool(true) int(0) bool(true) int(1) bool(true) int(23) bool(true) int(0) bool(true) int(0) bool(true) int(-1) bool(true) int(1) bool(true) int(-23) bool(true) int(23) bool(true) int(0) bool(true) int(1) bool(true) int(19) bool(true) int(0) bool(true) int(1) bool(true) int(35) bool(true) float(0) bool(false) float(1.1) bool(false) float(23.45) bool(false) float(0) bool(false) float(10000000000) bool(false) float(230000000000) bool(false) string(0) "" bool(false) string(1) "0" bool(false) string(1) "1" bool(false) string(2) "23" bool(false) string(2) "-0" bool(false) string(2) "+0" bool(false) string(2) "-1" bool(false) string(2) "+1" bool(false) string(3) "-23" bool(false) string(3) "+23" bool(false) string(2) "00" bool(false) string(2) "01" bool(false) string(3) "023" bool(false) string(3) "0x0" bool(false) string(3) "0x1" bool(false) string(4) "0x23" bool(false) string(3) "0.0" bool(false) string(3) "1.1" bool(false) string(5) "23.45" bool(false) string(4) "0e10" bool(false) string(4) "1e10" bool(false) string(5) "23e10" bool(false) string(4) "0abc" bool(false) string(4) "1abc" bool(false) string(5) "23abc" bool(false) string(5) "-0abc" bool(false) string(5) "+0abc" bool(false) string(5) "-1abc" bool(false) string(5) "+1abc" bool(false) string(6) "-23abc" bool(false) string(6) "+23abc" bool(false) string(5) "00abc" bool(false) string(5) "01abc" bool(false) string(6) "023abc" bool(false) string(6) "0x0abc" bool(false) string(6) "0x1abc" bool(false) string(7) "0x23abc" bool(false) string(6) "0.0abc" bool(false) string(6) "1.1abc" bool(false) string(8) "23.45abc" bool(false) string(7) "0e10abc" bool(false) string(7) "1e10abc" bool(false) string(8) "23e10abc" bool(false) string(3) "abc" bool(false) string(4) "abc0" bool(false) string(4) "abc1" bool(false) string(5) "abc23" bool(false) string(5) "abc-0" bool(false) string(5) "abc+0" bool(false) string(5) "abc-1" bool(false) string(5) "abc+1" bool(false) string(6) "abc-23" bool(false) string(6) "abc+23" bool(false) string(5) "abc00" bool(false) string(5) "abc01" bool(false) string(6) "abc023" bool(false) string(6) "abc0x0" bool(false) string(6) "abc0x1" bool(false) string(7) "abc0x23" bool(false) string(6) "abc0.0" bool(false) string(6) "abc1.1" bool(false) string(8) "abc23.45" bool(false) string(7) "abc0e10" bool(false) string(7) "abc1e10" bool(false) string(8) "abc23e10" bool(false) array(0) { } bool(false) array(2) { [0]=> int(0) [1]=> int(1) } bool(false)
Links
Variable Handling
- boolval
- debug_zval_dump
- doubleval
- empty
- floatval
- get_debug_type
- get_defined_vars
- get_resource_id
- get_resource_type
- gettype
- intval
- is_array
- is_bool
- is_callable
- is_countable
- is_double
- is_float
- is_integer
- is_iterable
- is_long
- is_null
- is_numeric
- is_object
- is_real
- is_resource
- is_scalar
- is_string
- isset
- print_r
- serialize
- settype
- strval
- unserialize
- unset
- var_dump
- var_export