當前位置: 首頁> 函數類別大全> is_numeric

is_numeric

檢測變量是否為數字或數字字符串
名稱:is_numeric
分類:變量處理
所屬語言:php
一句話介紹:檢查變量是數字還是數字字符串。

定義和用法

is_numeric()函數用於檢查變量是否為數字或數字字符串。

如果變量是數字或數字字符串,則此函數返回true (1),否則返回false /無返回值。

實例

檢查變量是否為數字或數字字符串:

 <?php
$a = 32 ;
echo "a is " . is_numeric ( $a ) . "<br>" ;

$b = 0 ;
echo "b is " . is_numeric ( $b ) . "<br>" ;

$c = 32.5 ;
echo "c is " . is_numeric ( $c ) . "<br>" ;

$d = "32" ;
echo "d is " . is_numeric ( $d ) . "<br>" ;

$e = true ;
echo "e is " . is_numeric ( $e ) . "<br>" ;

$f = null ;
echo "f is " . is_numeric ( $f ) . "<br>" ;
?>

親自試一試

文法

is_numeric ( variable ) ;
參數 描述
variable 必需。指定要檢查的變量。
同類函數
  • 返回資源(resource)類型 get_resource_type

    get_resource_type

    返回資源(resource)類型
  • 設置變量的類型 settype

    settype

    設置變量的類型
  • 檢測變量是否為數字或數字字符串 is_numeric

    is_numeric

    檢測變量是否為數字或數字字符串
  • is_int 的別名 is_long

    is_long

    is_int的別名
  • 檢測變量是否已設置並且非null isset

    isset

    檢測變量是否已設置並且非null
  • 獲取變量的類型(可以為數組、字符串、匿名類和對象返回更有用的輸出信息) get_debug_type

    get_debug_type

    獲取變量的類型(可以為數組、字符串、匿名
  • 檢查一個變量是否為空 empty

    empty

    檢查一個變量是否為空
  • 以易於理解的格式打印變量 print_r

    print_r

    以易於理解的格式打印變量
熱門文章