How to determine whether a variable exists in php

爱喝马黛茶的安东尼
Release: 2023-02-24 21:50:02
Original
4043 people have browsed it

How to determine whether a variable exists in php

Three ways for PHP to determine whether a variable exists:

1. bool isset (mixed var[,mixedvar [,mixed... ] )

Check whether the variable is set and it is not NULL.

If multiple parameters are passed in at one time, isset() will only return TRUE when all parameters are set. The calculation process is from left to right and will stop immediately when encountering an unset variable.

Related recommendations: "php tutorial"

2. bool empty (mixed $var)

Determine whether a variable is considered empty.

以下的东西被认为是空的:
"" (空字符串)
0 (作为整数的0)
0.0 (作为浮点数的0)
"0" (作为字符串的0)
NULL
FALSE
array() (一个空数组)
$var; (一个声明了,但是没有值的变量)
Copy after login

3. bool is_null (mixed $var)

The NULL type has only one value, which is the case-insensitive constant NULL.

The above is the detailed content of How to determine whether a variable exists in php. For more information, please follow other related articles on the PHP Chinese website!

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