@if(): is part of the conditional
operator directives. It is being used optionally along with
@else() and
@elseif() operators. The @if(): marks the
opening of the condition while it is also terminally ended by
the @endif; closing operator. The sample below shows how to apply this directive
<?php
namespace spoova\mi\windows\Routes;
use Route;
class Home extends Route {
function __construct() {
self::call($this, [
// declare accepted urls
lastUrl() => 'home';
// parse variable arguments
SELF::ARGS => [
'var' => 'foo'
]
]);
}
function home($args) {
self::load('home' => compile($args));
}
}
if condition. This is shown below
@if($var === 'foo'):
This is {{ $var }}
@elseif($var === 'bar'):
This is {{ $var }}
@else:
The value of $var is not defined.
@endif;
This is foo