Hello!

I understand the standard horizontal menu template BITRIX. It contains the following code checking the nesting level of the current and previous menu items:

<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?> <?= str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"])); ?> <? endif ?> 

If validation is performed, then open list tags are closed. But I just can not understand why to compare 2 times? That is, the current level is compared with the previous one, we get either true, or false and then compare again, using &&. Everything works fine if you write simply:

 <?if ($arItem["DEPTH_LEVEL"] < $previousLevel):?> 

    1 answer 1

    In php if ($previousLevel) is the same as if(!empty($previousLevel)) , but the first option is more concise. This condition simply checks if there is a $ previousLevel and whether it is empty, so that later when accessing it there are no exceptions well or Vorningov, I don’t remember exactly in php.

    I.e,

    Everything works fine if you write simply:

     <?if ($arItem["DEPTH_LEVEL"] < $previousLevel):?> 

    until such time as the case when $previousLevel is null