Home > Backend Development > PHP Problem > php isset empty difference

php isset empty difference

王林
Release: 2023-02-25 22:26:01
Original
3575 people have browsed it

php isset empty difference

PHP’s isset() function is generally used to detect whether a variable is set

Format:

bool isset ( mixed var [, mixed var [, ...]] )
Copy after login

Function:

Detect whether the variable is set

Return value:

If the variable does not exist, return FALSE; if If the variable exists and its value is NULL, it also returns FALSE; if the variable exists and its value is not NULL, it returns TRUE. When multiple variables are checked at the same time, TRUE is returned only when each single item meets the previous requirement, otherwise the result is FALSE.

More explanation:

After you release a variable using unset(), it will no longer be isset(). The PHP function isset() can only be used with variables. Passing any other parameters will cause a parsing error. Check whether a constant has been set using the defined() function.

PHP's empty() function determines whether the value is empty

Format:

bool empty ( mixed var )
Copy after login

Function:

Check whether a variable is empty

Return value:

If the variable does not exist, it returns TRUE; if the variable exists and its value For "", 0, "0", NULL,, FALSE, array(), var $var; and objects without any attributes, TRUE is returned; if the variable exists and the value is not "", 0, "0", NULL, FALSE, array(), var $var; and objects without any attributes, return FALSE.

More explanation:

The return value of empty() =!(boolean) var, but no warning message will be generated because the variable is undefined. empty() can only be used for variables. Passing any other parameters will cause a Paser error and terminate the operation. Check whether a constant has been set using the defined() function.

Recommended tutorial: PHP video tutorial

The above is the detailed content of php isset empty difference. 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