Home > Backend Development > PHP Tutorial > Summary of common judgment conditions in PHP

Summary of common judgment conditions in PHP

高洛峰
Release: 2023-03-05 15:32:02
Original
3471 people have browsed it

Types of commonly used judgment conditions

  • Variables such as: $var

  • isset()

  • empty()

  • Comparison operators such as: > < == != === !==

  • ##Logical operations Symbols such as:! && || or and

  • Specific type judgment, for example: is_null()/is_array()/is_int(), etc.

Variable

  • No matter what type the variable is, it will be converted to bool type

  • Empty strings and empty arrays are false

  • The value 0 and the string "0" are both false

  • The NULL type is false

  • NULL类型有三种情况:
    1、定义并赋值为null
    2、定义不赋值
    3、不定义(不存在的)
    Copy after login
    Copy after login
isset()

  • is mainly used to determine the NULL type. For other types, no matter what the value is, it is true

  • and is_null() are a pair of opposite functions.

empty()

  • and variables are a pair that have exactly the opposite effect

  • The range of judgment Larger than isset()

  • Empty strings and empty arrays are both true

  • The value 0 and the string "0" are both true

  • NULL types are all true

Types of commonly used judgment conditions

  • Variable example: $var

  • isset()

  • empty()

  • Comparison operators such as: > < == != === !==

  • Logical operators such as: ! && || or and

  • Specific type judgment, for example: is_null()/is_array()/is_int(), etc.

Variable

  • No matter what type the variable is, it will be converted to bool type

  • Empty strings and empty arrays are false

  • The value 0 and the string "0" are both false

  • The NULL type is false

NULL类型有三种情况:
1、定义并赋值为null
2、定义不赋值
3、不定义(不存在的)
Copy after login
Copy after login
isset()

  • is mainly used to determine the NULL type. For other types, no matter what the value is, it is true

  • and is_null() are a pair of opposite functions.

empty()

  • and variables are a pair that have exactly the opposite effect

  • The range of judgment Larger than isset()

  • Empty strings and empty arrays are both true

  • The value 0 and the string "0" are both true

  • NULL types are all true

##More summary of common PHP judgment conditions related Please pay attention to the PHP Chinese website for articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template