3. isset() Function
Versions: PHP, versions 4 and above
Description:
The isset() function is used to check whether a variable is
set or not.
It returns a Boolean(TRUE) if the testing variable contains
any value other than NULL or FALSE.
It returns a Boolean(FALSE) if the testing variable
contains a NULL or FALSE value.
Note: If a variable is already unset with the unset()
function, it will no longer be set.
Syntax: isset(variable1, variable2,….)
7. unset()
Versions: PHP, versions 4 and above
Description: The unset() function destroys a given
variable.
Return Value: No value is returned.
Syntax: unset(variable1, variable2,....)
8. unset() Example
$array = array(0, 1, 2, 3);
unset($array[2]);
Output: Array with 3 variables (0,1,3) remaining; the
value 2 was destroyed.
10. empty() Function
Versions: PHP, versions 4, 5 and 7
Description: Determines whether a variable is considered to be empty. A
variable is considered empty if it does not exist or if its value equals
FALSE.
Note: empty() does not generate a warning if the variable does not exist.
Syntax: empty(variable, variable2, ....)
bool empty (mixed $var) (“Mixed” implies multiple variable types, but not all
types.)
if(empty($stringvar))
{
// do something
}
11. empty() Function
Note: Prior to PHP 5.5, empty() only supports
variables; anything else will result in a parse error.
No warning is generated if the variable does not exist.
That means empty() is essentially the concise
equivalent to !isset($var) || $var == false.
12. empty() Function
Return Values: Returns FALSE if var exists and has a
non-empty, non-zero value. Otherwise returns
TRUE.
The following are considered to be empty:Empty
State
Description
"" an empty string
0 0 as an integer
0 0 as a float
"0" 0 as a string
NULL
FALSE
array() an empty array
$var; A declared variable without a value
assigned.