Complete the code to check if two variables are equal using loose comparison.
<?php $a = 5; $b = '5'; if ($a [1] $b) { echo 'Equal'; } else { echo 'Not equal'; } ?>
The == operator checks if two values are equal after type juggling (loose comparison).
Complete the code to check if two variables are equal using strict comparison.
<?php $x = 10; $y = '10'; if ($x [1] $y) { echo 'Strictly equal'; } else { echo 'Not strictly equal'; } ?>
The === operator checks if two values are equal and of the same type (strict comparison).
Fix the error in the code to correctly check if two variables are not equal using strict comparison.
<?php $a = 7; $b = '7'; if ($a [1] $b) { echo 'Not strictly equal'; } else { echo 'Strictly equal'; } ?>
The !== operator checks if two values are not equal or not of the same type (strict inequality).
Fill both blanks to create a dictionary (associative array) with keys as numbers and values as their strict equality check with 10.
<?php
$results = [
8 => (8 [1] 10),
10 => (10 [2] 10)
];
print_r($results);
?>Using === checks strict equality for both keys with 10.
Fill all three blanks to create an array filtering numbers strictly greater than 5 and loosely equal to '7'.
<?php $numbers = [3, 5, 7, '7', 10]; $filtered = array_filter($numbers, function($num) { return $num [1] 5 && $num [2] '7' && $num [3] 7; }); print_r($filtered); ?>
The code filters numbers greater than 5, loosely equal to '7', and strictly equal to 7.