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

Summary of common judgment conditions in PHP

高洛峰
高洛峰Original
2017-02-09 09:21:413455browse

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、不定义(不存在的)
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、不定义(不存在的)
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!

Statement:
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