PHP If / Else Statements Without Brackets
php
Solution
That is acceptable across version and will work for as long as you want to do only one thing within each control block. Using brackets does help to make it easier to track where blocks start and end, as well as future proofing for when you need to add just one more statement.
This post has a good summary of the various options for if/else blocks in PHP.
Problem
Is the following always acceptable code? It seems to work, but does it consistently work with all versions of PHP? ``` if ($x > $y) echo 'x is greater'; elseif ($x == $y) echo 'equal'; else echo 'y is greater'; ``` Thanks.