PHP-də isset komandası

Tutaq ki, bizim aşağıdakı dəyişənimiz var:

php<?php
  $test = null;
?>

Gəlin dəyişənin null olmadığını yoxlayan şərt yazaq:

php<?php
  $test = null;
  
  if ($test !== null) {
    echo '+++';
  } else {
    echo '---';
  }
?>

Belə bir yoxlamanı xüsusi isset komandası ilə daha rahat yerinə yetirmək olar:

php<?php
  $test = null;
  
  if (isset($test)) {
    echo '+++';
  } else {
    echo '---';
  }
?>

Dəyişənin təyin olunmadığını yoxlamaq da olar. Bunun üçün məntiqi NOT ilə isset şərtini inverasiya edək:

php<?php
  $test = null;
  
  if (!isset($test)) {
    echo '+++';
  } else {
    echo '---';
  }
?>
Задание 1

Aşağıdakı kodu öyrənilən teoriyaya əsasən dəyişin:

php<?php
  $test = null;
    
  if ($test == null) {
    echo '+++';
  } else {
    echo '---';
  }
?>
Задание 2

Aşağıdakı kodu öyrənilən teoriyaya əsasən dəyişin:

php<?php
  $test = null;
    
  if ($test != null) {
    echo '+++';
  } else {
    echo '---';
  }
?>