Support the ongoing development of Laravel.io →
posted 7 years ago
Last updated 2 years ago.
0

You cannot write both php if syntax and laravel blade @if syntax.

However, you can do like this:

@if

@else
<?php if(true){

}
?>
@endif
Last updated 7 years ago.
0

no. i write only @if(1==1) say 1 @else say 2 @endif

and got error Parse error: syntax error, unexpected 'else' (T_ELSE), expecting end of file

i look in storage /framework/views/f98d81a0de54cabe7fb82022fd2a7e61294e7c71.php

@if(1==1) say 1

<?php else: ?>

say 2

<?php endif; ?>
0

Inline if statements...

{{ 1===1 ? 'say 1' : 'say 2' }}

https://stackoverflow.com/questions/25284344/ternary-in-laravel-blade

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Burak Burak burakkaraoglu Joined 24 Jul 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.