is_numeric
檢測變量是否為數字或數字字符串
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 | 必需。指定要檢查的變量。 |