Hướng dẫn is_numeric in php
Hàm is_numeric() trong PHP có chức năng kiểm tra một biến có phải là một số hoặc một chuỗi gồm các chữ số hay không. Trong đó: Kết quả Các bạn cần cần lưu ý một số cách viết khác của số như: Các bạn có thể tham khảo thêm quy ước
numberic string trong PHP. Mời bạn đánh giá bài viết PHP programming Điều hướng bài viết(PHP 4, PHP 5, PHP 7, PHP 8) is_numeric — Finds whether a variable is a number or a numeric string Descriptionis_numeric(mixed Parametersvalue The variable being evaluated. Return Values Returns Changelog
ExamplesExample #1 is_numeric() examples
$tests as $element) { The above example will output: '42' is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337.0 is numeric '0x539' is NOT numeric '02471' is numeric '0b10100111001' is NOT numeric '1337e0' is numeric 'not numeric' is NOT numeric array ( ) is NOT numeric 9.1 is numeric NULL is NOT numeric '' is NOT numeric Example #2 is_numeric() with whitespace
$tests as $element) { Output of the above example in PHP 8: ' 42' is numeric '42 ' is numeric ' 9001' is NOT numeric '9001 ' is NOT numeric Output of the above example in PHP 7: ' 42' is numeric '42 ' is NOT numeric ' 9001' is NOT numeric '9001 ' is NOT numeric See Also
sobolanx at gmail dot com ¶ 11 years ago
moskalyuk at gmail dot com ¶ 16 years ago
ben at chico dot com ¶ 8 years ago
kouber at saparev dot com ¶ 18 years ago
Magnus Deininger, dma05 at web dot de ¶ 13 years ago
|