1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Document</title>
8</head>
9<body>
10 <form action="" method="post">
11 <h1>ISSET Demo</h1>
12 <input type="submit" value="Click here" name="btn1">
13 </form>
14</body>
15</html>
16<?php
17if(isset($_POST['btn1']))
18{
19 echo "button was set!";
20}
21?>
1/**
2 * Returns a bool (true or false)
3 */
4isset($x);
5/**
6 * Examples
7 */
8$x = 'myValue';
9if(isset($x)){
10 echo 'x is set';
11}
12/**
13 * this will echo out 'x is set'
14 */
15
16
17$x = null;
18if(isset($x)){
19 echo 'x is set';
20}
21/**
22 * This will NOT echo out 'x is set'
23 */
24
25
26if(isset($y)){
27 echo 'y is set';
28}
29/**
30 * This will NOT echo out 'y is set'
31 */
32
33
1The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL.
2
3This function returns true if the variable exists and is not NULL, otherwise it returns false.