숫자 체크 > Web 끄적임

본문 바로가기

사이트 내 전체검색

뒤로가기 뒤로가기

Web 끄적임

PHP 숫자 체크

페이지 정보

작성자 관리자 작성일 20-09-18 09:45 조회 10,617 댓글 0

본문

$tests = array(
"42",
1337,
0x539,
02471,
0b10100111001,
1337e0,
"not numeric",
array(),
9.1,
null
);

foreach ($tests as $element) {
if (is_numeric($element)) {
echo var_export($element, true) . " is numeric", PHP_EOL;
} else {
echo var_export($element, true) . " is NOT numeric", PHP_EOL;
}
}
------------------------------------------------------------
ctype_digit() - Check for numeric character(s)
is_bool() - Finds out whether a variable is a boolean
is_null() - Finds whether a variable is NULL
is_float() - Finds whether the type of a variable is float
is_int() - Find whether the type of a variable is integer
is_string() - Find whether the type of a variable is string
is_object() - Finds whether a variable is an object
is_array() - Finds whether a variable is an array
추천0 비추천 0

댓글목록 0

등록된 댓글이 없습니다.

Copyright © NEION All rights reserved.
PC 버전으로 보기