Làm cách nào để kiểm tra xem giá trị có bằng 0 trong PHP không?

Hàm isset() là một hàm sẵn có trong PHP để kiểm tra xem một biến có được đặt và không phải là NULL hay không. Hàm này cũng kiểm tra xem một biến, mảng hoặc khóa mảng được khai báo có giá trị null hay không, nếu có, isset() trả về false, nó trả về true trong tất cả các trường hợp có thể khác

cú pháp.  

bool isset( $var, mixed )

Thông số. Chức năng này chấp nhận nhiều hơn một tham số. Tham số đầu tiên của hàm này là $var. Tham số này dùng để lưu trữ giá trị của biến

Ví dụ.   

PHP




0 is set with isset function 
array is not set.
2

 

0 is set with isset function 
array is not set.
3

0 is set with isset function 
array is not set.
4

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
7
0 is set with isset function 
array is not set.
0

 

0 is set with isset function 
array is not set.
1
0 is set with isset function 
array is not set.
2
0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
4

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
7
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
9

 

0 is set with isset function 
array is not set.
00

________ 101 ________ 66 ________ 103 ________ 104

0 is set with isset function 
array is not set.
05

0 is set with isset function 
array is not set.
06

0 is set with isset function 
array is not set.
07
0 is set with isset function 
array is not set.
08_______101
0 is set with isset function 
array is not set.
90
0 is set with isset function 
array is not set.
91
0 is set with isset function 
array is not set.
92

________ 193 ________ 194 ________ 195 ________ 10

0 is set with isset function 
array is not set.
97

đầu ra.

0 is set with isset function 
array is not set.

 

chức năng rỗng ()

Hàm empty() là một cấu trúc ngôn ngữ để xác định xem biến đã cho là rỗng hay NULL. Các. Hàm trống () là phủ định hoặc bổ sung của hàm trống (). Hàm trống () đáng kể bằng. hàm isset() và. Hàm empty() bằng với hàm isset()

Ví dụ.   

PHP




0 is set with isset function 
array is not set.
2

 

0 is set with isset function 
array is not set.
3

0 is set with isset function 
array is not set.
20

 

0 is set with isset function 
array is not set.
21
0 is set with isset function 
array is not set.
22

 

0 is set with isset function 
array is not set.
23

0 is set with isset function 
array is not set.
24

0 is set with isset function 
array is not set.
1
0 is set with isset function 
array is not set.
26______627
0 is set with isset function 
array is not set.
26
0 is set with isset function 
array is not set.
21
0 is set with isset function 
array is not set.
30

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
07
0 is set with isset function 
array is not set.
21
0 is set with isset function 
array is not set.
34
0 is set with isset function 
array is not set.
35
0 is set with isset function 
array is not set.
0

0 is set with isset function 
array is not set.
9

 

________ 107 ________ 639 ________ 10

 

0 is set with isset function 
array is not set.
41

0 is set with isset function 
array is not set.
42
0 is set with isset function 
array is not set.
43

0 is set with isset function 
array is not set.
1
0 is set with isset function 
array is not set.
45____627
0 is set with isset function 
array is not set.
26
0 is set with isset function 
array is not set.
42
0 is set with isset function 
array is not set.
30

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
07
0 is set with isset function 
array is not set.
42
0 is set with isset function 
array is not set.
34
0 is set with isset function 
array is not set.
54
0 is set with isset function 
array is not set.
0

0 is set with isset function 
array is not set.
9

0 is set with isset function 
array is not set.
97

đầu ra.

0 is set with isset function 
array is not set.
0

 

Lý do để kiểm tra cả hai chức năng.
Tập hợp () và. Các hàm trống () tương tự nhau và cả hai sẽ trả về cùng một kết quả. Nhưng sự khác biệt duy nhất là. Hàm empty() sẽ không tạo bất kỳ cảnh báo hoặc thông báo điện tử nào khi biến không tồn tại. Nó là đủ để sử dụng một trong hai chức năng. Bằng cách kết hợp cả hai chức năng trong một chương trình gây ra thời gian trôi đi và sử dụng bộ nhớ không cần thiết.

Ví dụ.   

PHP




0 is set with isset function 
array is not set.
2

 

0 is set with isset function 
array is not set.
59

0 is set with isset function 
array is not set.
60

 

0 is set with isset function 
array is not set.
61

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
7
0 is set with isset function 
array is not set.
0

 

0 is set with isset function 
array is not set.
66

0 is set with isset function 
array is not set.
1
0 is set with isset function 
array is not set.
68
0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
4

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
34
0 is set with isset function 
array is not set.
75
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
9

 

0 is set with isset function 
array is not set.
78

________ 107 ________ 639 ________ 10

 

0 is set with isset function 
array is not set.
02

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
43

 

0 is set with isset function 
array is not set.
05

0 is set with isset function 
array is not set.
1
0 is set with isset function 
array is not set.
07
0 is set with isset function 
array is not set.
27
0 is set with isset function 
array is not set.
26
0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
4

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
34
0 is set with isset function 
array is not set.
16
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
9

đầu ra.

0 is set with isset function 
array is not set.
9

 

PHP là ngôn ngữ kịch bản phía máy chủ được thiết kế dành riêng cho phát triển web. Bạn có thể học PHP từ đầu bằng cách làm theo Hướng dẫn PHP và Ví dụ về PHP này

Cách kiểm tra 0. 00 trong PHP?

Hàm PHP empty() . Các giá trị sau ước tính trống. 0. 0. 0.

NULL hay 0 trong PHP?

Để xác định là null hoặc zero bởi. is_int($var) nếu biến là số hoặc chuỗi số. Để xác định Zero, sử dụng is_numeric($var) cũng là giải pháp hoặc sử dụng $var === 0. is_null($var) nếu một biến là NULL

Làm cách nào để phân biệt 0 và NULL PHP?

Zero là một int được xác định với giá trị 0 NULL là một biến không xác định không chứa giá trị. Cũng giống như sự khác biệt giữa màu trắng và trong suốt

0 có được coi là NULL không?

'\0' được xác định là ký tự rỗng . Nó là một ký tự có tất cả các bit được đặt thành 0. Điều này không có gì để làm với con trỏ.