if-else quruluşunda qısaldılmış if

Tutaq ki, məsələn, biz bilmək istəyirik ki, $test dəyişəni true qiymətinə bərabərdirmi. Bu halda if quruluşunu belə yazmaq olar:

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

Proqramlaşdırma zamanı belə yoxlamalar çox tez-tez tələb olunur, ona görə də onlar üçün daha zərif qısaldılmış forma mövcuddur: if ($test == true) əvəzinə sadəcə if ($test) yazmaq olar.

Gəlin kodumuzu qısaldılmış formada yenidən yazaq:

php<?php
  $test = true;
  
  if ($test) { // ekvivalent if ($test == true)
    echo '+++';
  } else {
    echo '---';
  }
?>

Tutaq ki, indi biz $test dəyişəninin true-yə bərabər OLMAMASINI yoxlayırıq:

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

Bu halda qısaldılmış sintaksis belə görünəcək:

php<?php
  $test = true;
  
  if (!$test) { // məntiqi DEYİL istifadə edirik
    echo '+++';
  } else {
    echo '---';
  }
?>

false üçün yoxlamada da oxşar qısaltma mövcuddur. Tutaq ki, belə bir kod verilmişdir:

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

$test == false şərti əslində $test != true ilə eyni şeydir:

php<?php
  $test = true;
  
  if ($test != true) { // ekvivalent if ($test == false)
    echo '+++';
  } else {
    echo '---';
  }
?>

Yaxşı, belə bir şərti artıq əvvəlki misalda qısaltmağı öyrənmişik. Gəlin qisaldaq:

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

Aşağıdakı kodu qısaldılmış müqayisədən istifadə etməklə yenidən yazın:

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

Aşağıdakı kodu qısaldılmış müqayisədən istifadə etməklə yenidən yazın:

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

Aşağıdakı kodu qısaldılmış müqayisədən istifadə etməklə yenidən yazın:

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

Aşağıdakı kodu qısaldılmış müqayisədən istifadə etməklə yenidən yazın:

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