Php and infinite subcategories

I have found an article about php and subcategories here:

I have a question about why

 if ($has_childs === false)



                                $has_childs = true;



Thanks in advance

perhaps because of the comment you omitted

//don’t print ‘<ul>’ multiple times

I know but I cant understand the logic!

$has_childs is a switch, used to display the ul and /ul tags at the beginning and end of the list of child categories of a parent category.
At the beginning of the while loop, it’s set to false. Then, inside the loop, the first time the if is true ($has_childs is false), so it displays the opening ul tag, and sets the switch to true. Since it’s value is true now, from now on the if will be false, and no more ul opening tags will be displayed.
Then, once the loop ends, if the if outside the loop is true, the closing ul tag is displayed.

thanks for reply