15 1 0 4000 1 https://codeblock.co.za 300 true 0
theme-sticky-logo-alt

isset()

0 Comments

Programming Language

PHP [Versions: 4, 5, 7, 8]

Syntax

Typical Usage

Used to check if a PHP variable is declared and is something other than null. Most often used for GET and POST parameters.

Accepted Parameters

  • variable (mixed) (Required): The variable you need to check for.

Return Value(s)

Returns true if the variable exists and has any value other than null and false if not.

Notes

isset() only works with variables. Passing anything else will result in a parse error. If you need to check if a constant has been defined, use the defined() function.

Examples of isset()

Example 1

<?php
if (isset($_GET['name'])) {
    echo $_GET['name'];
}

Example 2

<?php

if (isset($name)) {
    echo 'Hello ' . $name;
}
else {
   echo 'Hello User';
}

Was This Helpful?

Previous Post
array_key_exists()
Next Post
strtolower()

0 Comments

Leave a Reply