What does isset mean in php
isset() is a built-in function in PHP used to detect whether a variable is declared, and its return value is of Boolean type. If the variable does not exist, it returns FALSE; 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.
The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer
The isset() function in PHP is used for detection Whether the variable is declared and non-NULL. This function returns a Boolean value, i.e. true/false.
Format:
bool isset ( mixed var [, mixed var [, ...]] )
Return value:
If the variable does not exist, return FALSE
if If the variable exists and its value is NULL, FALSE will also be returned. variable, TRUE will be returned only when each single item meets the previous requirement, otherwise the result will be FALSE
If a variable has been released using unset(), it will no longer be isset(). If you use isset() to test a variable that is set to NULL, it will return FALSE. Also note that a NULL byte ("\0") is not equivalent to PHP's NULL constant. Warning: isset() can only be used with variables, because passing any other parameters will cause a parsing error. If you want to check whether a constant has been set, use the defined() function.
Example:
<?php $var = ''; // 结果为 TRUE,所以后边的文本将被打印出来。 if (isset($var)) { echo "This var is set so I will print."; } // 在后边的例子中,我们将使用 var_dump 输出 isset() 的返回值。 // the return value of isset(). $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 ?>
This is also valid for elements in an array:
<?php $a = array ('test' => 1, 'hello' => NULL, 'pie' => array('a' => 'apple')); var_dump(isset($a['test'])); // TRUE var_dump(isset($a['foo'])); // FALSE var_dump(isset($a['hello'])); // FALSE // 键 'hello' 的值等于 NULL,所以被认为是未置值的。 // 如果想检测 NULL 键值,可以试试下边的方法。 var_dump(array_key_exists('hello', $a)); // TRUE // Checking deeper array values var_dump(isset($a['pie']['a'])); // TRUE var_dump(isset($a['pie']['b'])); // FALSE var_dump(isset($a['cake']['a']['b'])); // FALSE ?>
[Recommended learning: "
PHP Video Tutorial"]
The above is the detailed content of What does isset mean in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
