Thật tốt khi biết chính xác những gì có trong biến của bạn, đặc biệt nếu bạn đang kiểm tra không chính xác so với null hoặc na vs true hoặc false so với trống hoặc 0.
Tôi chỉ sử dụng trống cho 'và nulls vì các hàm chuỗi có xu hướng không nhất quán. Nếu kiểm tra trống
Nếu không chính xác về mặt ngữ nghĩa giống như một trong các giá trị trên, thì hãy khởi tạo biến ở đầu đến giá trị đó.
(Php 4> = 4.0.4, Php 5, Php 7, Php 8)
IS_NULL - tìm thấy một biến là null
— Finds whether a variable is null
Sự mô tả
is_null (hỗn hợp $value
): bool(mixed $value
): bool
Thông số
________số 8 Biến được đánh giá.
Trả về giá trị
Trả về true
nếu value
là null,
isset($var)
1 nếu không.true
if value
is null, isset($var)
1 otherwise. Ví dụ
Ví dụ #1 is_null () ví dụis_null()
example
isset($var)
2isset($var)
3isset($var)
4Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
Xem thêm
- Loại
null
null
type - ISSET () - Xác định xem một biến được khai báo và khác với NULL
- is_bool () - Tìm hiểu xem một biến có phải là boolean
- is_numeric () - Tìm một biến là số hay chuỗi số
- 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
- 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
- is_array () - Tìm xem một biến có phải là một mảng không
Malfist ¶ ¶
14 năm trước
isset($var)
6isset($var)
7isset($var)
8isset($var)
9$var === true
$var === 0
$var === ""
0$var === true
$var === 0
$var === ""
1 George tại Fauxpanels Dot Com ¶ ¶
13 năm trước
$var === true
$var === 0
$var === ""
2$var === true
$var === 0
$var === ""
3$var === true
$var === 0
$var === ""
4$var === true
$var === 0
$var === ""
5$var === true
$var === 0
$var === ""
1 Liên hệ với DOT 01834E2C tại Renegade334 dot me dot uk ¶ ¶
7 năm trước
$var === true
$var === 0
$var === ""
7$var === true
$var === 0
$var === ""
8$var === true
$var === 0
$var === ""
9$var === true
$var === 0
$var === ""
1 Ahamilton9 ¶ ¶
6 tháng trước
empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
1empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
2$var === true
$var === 0
$var === ""
1 Ai Dot Unstmann tại COMBOUND DOT DE ¶ ¶
14 năm trước
empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
4empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
5empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
6empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
7empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
8 George tại Fauxpanels Dot Com ¶ ¶
13 năm trước
empty($var)
$var // in a boolean context
// This does the same as above, but is less clear because you are
// casting to false, which has the same values has empty, but perhaps
// may not one day. It is also easier to search for bugs where you
// meant to use ===
$var == false
9 Liên hệ với DOT 01834E2C tại Renegade334 dot me dot uk ¶ ¶
14 năm trước
$var = ''
... //some code
if ($var === '') blah blah.
0$var = ''
... //some code
if ($var === '') blah blah.
1$var = ''
... //some code
if ($var === '') blah blah.
2$var = ''
... //some code
if ($var === '') blah blah.
3$var = ''
... //some code
if ($var === '') blah blah.
4$var === true
$var === 0
$var === ""
1
George tại Fauxpanels Dot Com ¶ ¶
13 năm trước
$var = ''
... //some code
if ($var === '') blah blah.
6$var = ''
... //some code
if ($var === '') blah blah.
7$var = ''
... //some code
if ($var === '') blah blah.
8$var = ''
... //some code
if ($var === '') blah blah.
9Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
0$var === true
$var === 0
$var === ""
1 Liên hệ với DOT 01834E2C tại Renegade334 dot me dot uk ¶ ¶
7 năm trước
Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
2Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
3Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
4Notice: Undefined variable: inexistent in ...
bool(true)
bool(true)
5$var === true
$var === 0
$var === ""
1Vô giá trị.Giá trị null là giả.null values are falsy.