search
HomeBackend DevelopmentPHP ProblemHow to use isset() function in php

How to use isset() function in php

Jul 30, 2020 pm 04:12 PM
isset()php

How to use the isset() function in php: The isset() function is used to detect whether the variable has been set and is not NULL. The specific usage is as follows: [isset($a)]. Returns TRUE if the specified variable exists and is not NULL, otherwise returns FALSE.

How to use isset() function in php

isset() function is used to detect whether the variable has been set and is not NULL.

(Recommended tutorial: php graphic tutorial)

If you have used unset() to release a variable, and then pass isset() to judge, it will return FALSE.

If isset() is used to test a variable that is set to NULL, FALSE will be returned.

Also note that the null character ("\0") is not equivalent to PHP's NULL constant.

Function syntax:

bool isset ( mixed $var [, mixed $... ] )

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 no one is encountered halfway. It will stop immediately when the variable is set.

Return value:

If the specified variable exists and is not NULL, TRUE is returned, otherwise FALSE is returned.

(Learning video recommendation: php video tutorial)

Example:

<?php
$var = &#39;&#39;; 
// 结果为 TRUE,所以后边的文本将被打印出来。
if (isset($var)) {
    echo "变量已设置。" . PHP_EOL;
}
 
$a = "test";
$b = "anothertest"; 
var_dump(isset($a));      // TRUE
var_dump(isset($a, $b)); // TRUE
unset ($a); 
var_dump(isset($a));     // FALSE
var_dump(isset($a, $b)); // FALSE
$foo = NULL;var_dump(isset($foo));   // FALSE
?>

Output result:

变量已设置。
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)

The above is the detailed content of How to use isset() function in php. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor