숫자 체크 > PHP

본문 바로가기
사이트 내 전체검색

PHP

숫자 체크

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 6,618회 작성일 20-09-18 09:45

본문

$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

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

Copyright © neion.co.kr All rights reserved.