if is not set php code example
Example 1: is null php
// The is_null() function checks whether a variable is NULL or not. This function returns true (1) if the variable is NULL, otherwise it returns false/nothing.
<?php
$var = NULL;
if (is_null($var)) {
echo "yes, is null";
} else {
echo "not null";
}
?>
Example 2: isset in php
isset($x);
$x = 'myValue';
if(isset($x)){
echo 'x is set';
}
$x = null;
if(isset($x)){
echo 'x is set';
}
if(isset($y)){
echo 'y is set';
}
Example 3: error php
$errors = array();
if (........){
$errors['the_name_of_the_error']='the error message';
}
if(empty($_POST['password']) ||
$_POST['password'] != $_POST['password_confirm']){
$errors['errors']= "You must enter a valid password";
}