Avoid a loose comparison

Take your time, follow the code and check your understanding.

The codePHP arrays and requests
<?php
$enabled = "0";
if ($enabled == false) { echo "off"; }
Your answer4 min · no timer
What needs fixing?

Show solution and explanation

Loose comparison performs coercion. PHP also treats the string "0" as falsy. Validate the input format, then compare the intended types explicitly.

Use an explicit input contract and strict comparisons when types matter.