This question already has an answer here:
I've always been wondering about this since I began learning PHP. As many other new-beginners, I placed semicolons all over the place, and for some reason, placing them after an if statement compiles and runs, but not like one would expect.
Example:
<?php
$foo = "bar";
if ($foo == "bar") // Correct way
echo "OK";
if ($foo == "bar"); // Incorrect way
echo "OK";
if ($foo == "derp"); // Incorrect way again
echo "NO";
?>
This will output:
OKOKNO
Why is this? What is the intended usage for this? Just a twerk left in the code that for some reason has never been fixed? It looks like the compiler just skips the entire if-statement all together.
</div>