为什么if / elseif语句的顺序在laravel中很重要?

Why does the following code work:

@if (Auth::guest())
@elseif(Auth::user())
    <p>test</p>
@endif

and the following DOES NOT work?

@if(Auth::user())
    <p>test</p>
@elseif (Auth::guest())
@endif

It's the same logic, isn't it?

If your if the condition is getting satisfied then the PHP will not bother executing the else or elseif statement.

For an example

$flag = true;

if ($flag) {
  echo "true";
} elseif($flag) {
  echo "true inside flag";
}

This will echo out true Even if the condition inside elseif is also true, it will not get executed.