Support the ongoing development of Laravel.io →
posted 6 years ago
Last updated 1 year 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 6 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-larave...

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.