Hướng dẫn is string a number php? - string có phải là số php không?

(Php 4, Php 5, Php 7, Php 8)

is_numeric - tìm thấy một biến là số hay chuỗi số Finds whether a variable is a number or a numeric string

Sự mô tả

is_numeric (hỗn hợp $value): bool(mixed $value): bool

Thông số

value

Biến được đánh giá.

Trả về giá trị

Trả về true nếu value là một số hoặc chuỗi số, false nếu không.true if value is a number or a numeric string, false otherwise.

Thay đổi

Phiên bảnSự mô tả
8.0.0 is_numeric (hỗn hợp $value): booltrue. Previously, false was return instead.

Thông số

valueis_numeric() examples

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
1

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
2

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

Biến được đánh giá.

'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

Trả về giá trịis_numeric() with whitespace

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
4

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
2

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

Trả về true nếu value là một số hoặc chuỗi số, false nếu không.

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric

Thay đổi

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric

Phiên bản

  • Các chuỗi số kết thúc bằng khoảng trắng ("42 ") bây giờ sẽ trả về true. Trước đây, false đã trở lại thay thế.
  • Ví dụ
  • Ví dụ #1 is_numeric () ví dụ
  • Ví dụ trên sẽ xuất ra:
  • Ví dụ #2 is_numeric () với khoảng trắng
  • Đầu ra của ví dụ trên trong Php 8:
  • Đầu ra của ví dụ trên trong Php 7:
  • Xem thêm
  • Chuỗi số
  • ctype_digit () - Kiểm tra (các) ký tự số

is_bool () - Tìm hiểu xem một biến có phải là boolean

is_null () - tìm thấy một biến có phải là null

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
7

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
8

' 42' is numeric
'42 ' is numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
9

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
0

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
1

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
2

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

is_float () - Tìm liệu loại biến có nổi không

is_int () - Tìm loại biến có số nguyên không

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
4

is_String () - Tìm loại biến là chuỗi

is_Object () - Tìm xem một biến có phải là một đối tượng

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
5

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
6

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
7

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

is_array () - Tìm xem một biến có phải là một mảng không

Filter_var () - Lọc một biến có bộ lọc được chỉ định

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
9

$value0

$value1

$value2

$value3

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

Sobolanx tại gmail dot com ¶

11 năm trước

$value5

$value6

$value7

' 42' is numeric
'42 ' is NOT numeric
' 9001' is NOT numeric
'9001 ' is NOT numeric
3

PHP là một chuỗi hoặc số?

Định nghĩa và sử dụng hàm is_numeric () kiểm tra xem một biến là số hoặc chuỗi số.Hàm này trả về true (1) nếu biến là số hoặc chuỗi số, nếu không nó sẽ trả về false/không có gì.The is_numeric() function checks whether a variable is a number or a numeric string. This function returns true (1) if the variable is a number or a numeric string, otherwise it returns false/nothing.

Là một số một chuỗi?

Một chuỗi bao gồm một hoặc nhiều ký tự, có thể bao gồm các chữ cái, số và các loại ký tự khác.Bạn có thể nghĩ về một chuỗi như văn bản đơn giản.Một chuỗi đại diện cho dữ liệu chữ và số.. You can think of a string as plain text. A string represents alphanumeric data.

Chuỗi số PHP là gì?

Một chuỗi PHP được coi là số nếu nó có thể được hiểu là INT hoặc FLOAT.Chính thức kể từ Php 8.0.0: khoảng trắng \ S* lnum [0-9]+ dnum ([0-9]*) [\.] {Lnum}) |({Lnum} [\.if it can be interpreted as an int or a float. Formally as of PHP 8.0.0: WHITESPACES \s* LNUM [0-9]+ DNUM ([0-9]*)[\. ]{LNUM}) | ({LNUM}[\.

PHP có phải là một chữ số không?

Hàm is_numeric () trong ngôn ngữ lập trình PHP được sử dụng để đánh giá xem một giá trị là số hoặc chuỗi số.Các chuỗi số chứa bất kỳ số lượng chữ số nào, các dấu hiệu tùy chọn như + hoặc -, số thập phân tùy chọn và theo cấp số nhân tùy chọn.Do đó, +234.5E6 là một chuỗi số hợp lệ.. Numeric strings contain any number of digits, optional signs such as + or -, an optional decimal, and an optional exponential. Therefore, +234.5e6 is a valid numeric string.